Created
September 1, 2010 18:32
-
-
Save aboekhoff/561122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; pairs | |
(define-type Pair a b) | |
(define-type Empty) | |
(define Pair:foldl | |
f x (Pair a b) -> (foldl f (f x a) b)) | |
(define Pair:first | |
(Pair a _) -> (Some a)) | |
(define Pair:rest | |
(Pair _ (Empty)) -> Empty | |
(Pair _ a) -> a) | |
;;;; snip | |
(define-interface Foldable | |
foldl XS (F X XS) | |
foldr XS (F X XS)) | |
(extend-interface Foldable | |
array | |
(foldl array:foldl) | |
(foldr array:foldr) | |
array-like | |
(foldl array:foldl) | |
(foldr array:foldr) | |
Pair | |
(foldl Pair:foldl) | |
Empty | |
(foldl (fn (_ X _) X))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment