Last active
October 10, 2020 16:31
-
-
Save witt3rd/6543b6bfdb8cea3705a0d20d9d7dfc47 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
data Foo a = Bar a | |
| Baz (Foo a) (Foo a) | |
fooEq : DecEq a => a -> a -> Foo a -> Foo a -> Maybe (Foo a) | |
fooEq x y f g = case decEq x y of | |
Yes _ => Just (Baz f g) | |
No _ => Nothing | |
comb : DecEq a => Foo a -> Foo a -> Maybe (Foo a) | |
comb f@(Bar x ) g@(Bar y ) = fooEq x y f g -- < ok | |
comb f@(Bar x ) g@(Baz y z) = fooEq x y f g -- < error | |
comb f@(Baz x z) g@(Bar y ) = fooEq x y f g -- < error | |
comb f@(Baz x z) g@(Baz y w) = fooEq x y f g -- < error | |
{- | |
When checking right hand side of comb with expected type | |
Maybe (Foo a) | |
When checking an application of function Main.fooEq: | |
Unifying a and Foo a would lead to infinite value | |
-} |
Author
witt3rd
commented
Oct 10, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment