[Haskell-cafe] checking types with type families

Ivan Miljenovic ivan.miljenovic at gmail.com
Tue Jun 22 23:52:58 EDT 2010


On 23 June 2010 13:46, Evan Laforge <qdunkan at gmail.com> wrote:
> I have a parameterized data type:
>
>> data Val result = VNum Double | VThunk (SomeMonad result)
>> type Environ result = Map Symbol (Val result)
>
> I have a class to make it easier to typecheck Vals:
>
>> class Typecheck a where
>>   from_val :: Val result -> Maybe a

I think your problem here is that there's no mention of `a' on the
left-hand size of from_val's type signature; you either need to use
MPTC+fundep to associate what result is compared to a, or else use a
phantom type parameter of Val to make it "data Val result a = ..." and
then "from_val :: Val result a -> Maybe a".

SPJ's paper on type families has this situation arising in the section
on defining a graph class.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list