Skip to content

Instantly share code, notes, and snippets.

@deech
Created June 5, 2016 12:46
Show Gist options
  • Save deech/95a6211fb51bb473059255879f4a6f03 to your computer and use it in GitHub Desktop.
Save deech/95a6211fb51bb473059255879f4a6f03 to your computer and use it in GitHub Desktop.
(define string-concat
{ (list string) --> string }
[] -> ""
[S] -> S
[S | Ss] -> (@s S " " (string-concat Ss)))
(datatype verified-types-for-lists
_______________________________________
(empty? Xs) : verified >> Xs : (list A);
_______________________________________
(cons? Xs) : verified >> Xs : (list A);)
(define ->str
{ A --> string }
Xs -> "()" where (empty? Xs)
Xs -> (@s "(" (string-concat (map ->str Xs)) ")") where (cons? Xs)
Str -> (str Str))
(datatype type-reps
_____________________________________________
X : (type-rep A) >> (get X type-rep) : string;
let Tag (put (eval X) type-rep (->str A))
(tag-value-with-rep X A);
X : A; (tag-value-with-rep X A);
__________________________________________
X : (type-rep A);)
(define type-of
{ (type-rep A) --> string }
X -> (get X type-rep))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment