PLT Scheme 4.0 is out!
Monday, June 16th, 2008Typed 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 =)