Skip to content

Instantly share code, notes, and snippets.

@JavierGelatti
Created April 29, 2024 00:07
Show Gist options
  • Save JavierGelatti/3025938e81471b625c8276c49ab3614d to your computer and use it in GitHub Desktop.
Save JavierGelatti/3025938e81471b625c8276c49ab3614d to your computer and use it in GitHub Desktop.
Example of type checker not being able to unify stuff after inlining a function
data IsEmpty : List Char -> Type where
Empty : IsEmpty []
Uninhabited (IsEmpty (x::xs)) where
uninhabited Empty impossible
decideIsEmpty : (cs : List Char) -> Dec (IsEmpty cs)
decideIsEmpty cs = case cs of
[] => Yes Empty
(x :: xs) => No uninhabited
decideIsEmptyString : (s : String) -> Dec (IsEmpty (unpack s))
decideIsEmptyString s = decideIsEmpty (unpack s)
decideIsEmptyString' : (s : String) -> Dec (IsEmpty (unpack s))
decideIsEmptyString' s = case unpack s of
[] => Yes Empty
(x :: xs) => No uninhabited
decideIsEmptyString'' : (s : String) -> Dec (IsEmpty (unpack s))
decideIsEmptyString'' s = case unpack s of
[] => Yes Empty
(x :: xs) => No ?_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment