haskell - Data family instance binding illegally to built in syntax: () -
i'm trying define data type family, 1 of parameters results in type of empty tuple ()
, doesn't compile. here minimal working example:
{-# language typefamilies #-} data family f data instance f int = ()
the compiler error thrown says "illegal binding of built-in syntax: ()
". why getting error, though i'm not trying change definition of ()
, rather set output of computation (evaluation of type family)?
for it's worth, program compiled when ()
changed bool
instead.
with data families, you're supposed provide adt or gadt definition on right side of equation. ()
not valid definition of constructor. data instance f int = bool
declares single constructor name bool
, works, doesn't have type bool
. it's bool
available constructor name.
what you're trying can realized type families instead:
type family f type instance f int = () -- or in closed form type family f f int = ()
or can give right hand side data instance which's equivalent ()
:
data instance f int = funit
Comments
Post a Comment