diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-01-19 22:46:39 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-01-19 22:46:39 +0100 |
commit | c7619a27f841d24b5acb4c99ed486e95bd5130d8 (patch) | |
tree | 9aae2e1c9665b83090e1c3d80f71c0b9fdffea34 /examples | |
parent | e13b0a681108697f8b67d8c836edd54c042aad55 (diff) |
Noodling on the type checker
Diffstat (limited to 'examples')
-rw-r--r-- | examples/tc.hs | 10 | ||||
-rw-r--r-- | examples/test-kinds.hs | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/examples/tc.hs b/examples/tc.hs new file mode 100644 index 0000000..c27c736 --- /dev/null +++ b/examples/tc.hs @@ -0,0 +1,10 @@ +data Bool = False | True +data List a = Nil | Cons a (List a) + +isNil :: List a -> Bool +isNil Nil = True +isNil (Cons _ _) = False + +map :: (a -> b) -> List a -> List b +map _ Nil = Nil +map f (Cons x l) = Cons (f x) (map f l) diff --git a/examples/test-kinds.hs b/examples/test-kinds.hs index 1e2c18c..ddd4817 100644 --- a/examples/test-kinds.hs +++ b/examples/test-kinds.hs @@ -8,6 +8,8 @@ data Either a b = Left a | Right b data ExceptT e m a = ExceptT (Either e (m a)) +data ExceptT2 e m a = ExceptT2 (m (Either e a)) + data TreeF a r = NodeF r a r | LeafF |