The first thing I did was, define a Task, which generalizes over all
the above defined (and future Taskables)
data Task a where
Task :: (Taskable a) => a -> Task a
instance Functor Task where
fmap:: (Taskable a, Taskable b) -> (a -> b) -> Task a -> Task b --- THIS DOES NOT WORK
fmap f (Task a) = Task $ f a
But, I realized that I cannot define an fmap over a type constraint.
My questions are:
1. Is there any way to do this. I see there is an answer of SO. I wanted
to make sure if there were any improvements to this since that answer'
was posted.
http://stackoverflow.com/questions/17157579/functor-instance-for-a-gadt-with-type-constraint2. Secondly, I would like to know why this is not possible. Is it a current
limitation of GHC or if there is some fundamental category theory concepts
that dis-allows such declarations that I need to grok!
Appreciate any help on this. Thank you!