Skip to content

Instantly share code, notes, and snippets.

@ympbyc
Last active December 29, 2015 04:59
Show Gist options
  • Save ympbyc/7618886 to your computer and use it in GitHub Desktop.
Save ympbyc/7618886 to your computer and use it in GitHub Desktop.
ADT
(data (list a)
(cons a (list a))
nil)
(data (tree a)
(node a (forest a)))
(data (forest a)
(list (tree a)))
(typefn true a a a)
(typefn cons a (list a) (list a))
(typefn car (list a) a)
(typefn cdr (list a) (list a))
(data (list a)
(cons a (list a))
nil)
;; --> generates -->
(typefn cons a (list a) (list a))
(= cons x y f (f x y))
(= nil 'nil)
;; user defines accessors
(= car xs (xs true))
(= cdr xs (xs false))
;;;;;;;;;;;;;;;;;;;;
(data (tree a)
(node a (forest a)))
(data (forest a)
(list (tree a)))
;; --> generates -->
(= node x y f (f x y))
;; user defines accessors
(= tree-root nd (nd true))
(= tree-forest nd (nd false))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment