In many cases I find myself wanting to emulate e.g. Idris’s {x : A}
syntax, albeit it seems to me that this isn’t possible in general in Haskell.
For functions, you can add a forall
.
For data
and newtype
, you can use GADT-syntax.
E.g.
-- I use a variant of this in production
newtype Cont :: forall (r :: Type). Type -> Type where
Cont :: forall r a. {runCont :: ((a -> r) -> r)} -> Cont @r a
What can be done for type families and/or type synonyms?
I can’t seem to do anything like the following
-- There doesn't seem to be a syntax for this?
type SomeIdentity {a} = Identity a
-- `x` isn't in scope, and even then, arity mismatch I assume
type family SomeIdentity' :: forall (x :: Type). Type where
SomeIdentity' = Identity x
Is there any way to do this with type families?