PLT Scheme 4.0 is out!

PLT website

Typed Scheme is fun:

  #lang typed-scheme
  (define-struct: Nothing ())
  (define-struct: (a) Just ([v : a]))  
 
  (define-type-alias (Maybe a) (U Nothing (Just a)))  
 
  (: find (Number (Listof Number) -> (Maybe Number)))
  (define (find v l)
  (cond [(null? l) (make-Nothing)]
        [(= v (car l)) (make-Just v)]
        [else (find v (cdr l))]))

Though I couldn’t even deconstruct a value returned by this function & docs are very scarce. And I really doubt the idea, but nevertheless it’s fun =)

2 Responses to “PLT Scheme 4.0 is out!”

  1. Sam TH Says:

    Here’s an example of how to deconstruct such a value:

    (let* ([l (list 1 2 3 4)]
            [v (find 3 l)])
        (if (Just? v)
            (Just-v v)
            (error 'not-found)))

    Thanks for trying Typed Scheme!

  2. jartur Says:

    Oh, I’ll try that.
    Thanks.

Leave a Reply

Tips [+]