Last active
August 28, 2018 21:12
-
-
Save frenchy64/c1ee13698ee27f84c3aea4f2b1e8bfe7 to your computer and use it in GitHub Desktop.
This file contains 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
(ns colored-lti-clj.core) | |
(defalias List | |
(TFn [a] | |
'{:match (All [b] [(ListVisitor a b) :-> b])})) | |
(defalias ListVisitor | |
(TFn [a b] | |
'{:caseNil (All [:-> b]) | |
:caseCons (All [a (List a) :-> b])})) | |
(ann Nil (All [a] [:-> (List a)])) | |
(defn Nil [] | |
{:match (fn [v] ((:caseNil v)))}) | |
(ann Cons (All [a] [a (List a) :-> (List a)])) | |
(defn Cons [x xs] | |
{:match (fn [v] ((:caseCons v) x xs))}) | |
(ann append (All [c] [(List c) (List c) :-> (List c)])) | |
(defn append [xs ys] | |
((:match xs) | |
{:caseNil (fn [] ys) | |
:caseCons (fn [x xs1] | |
(Cons x (append xs1 ys)))})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment