[Haskell-cafe] Re: Existentials and SYB [Was: GADTs and Scrap your
Boilerplate]
Oscar Finnsson
oscar.finnsson at gmail.com
Sat May 22 09:49:59 EDT 2010
>> enDataI :: (Int -> DataBox)
>> enDataI = DataBox
>>
>> enDataB :: (Bool -> DataBox)
>> enDataB = DataBox
>>
>> instance Data DataBox where
>> gfoldl k z (DataBox d) = z DataBox `k` d
>> gunfold k z c = (if True then k (z enDataI) else k (z enDataB))
>
Interesting solution but I'm not smart enough to see how the solution
can be generalized to any data type that's an instance of Data. Do I
have to repeat the "if then else" for every instance of the Data type
class (which I can't) or is there some other way?
Oscar
More information about the Haskell-Cafe
mailing list