External Publication
Visit Post

Type level programming: Dealing with ambiguous type error

Haskell Community [Unofficial] April 14, 2026
Source

tomjaguarpaw:

What will allow you to do that is forall ->.

No, matching on types is not (and should not be) possible even with full dependent types like in Agda. I hope this is not a planned feature.

What you can do is create a data type and map that to the type level:

data MyType = TInt | TBool

typeOfMyType :: MyType -> Type
typeOfMyType TInt = Int
typeOfMyType TBool = Bool

negateLike :: forall (t :: MyType) -> typeOfMyType t -> typeOfMyType t
negateLike TInt x = -x
negateLike TBool x = not x

Discussion in the ATmosphere

Loading comments...