[Haskell-cafe] newtype deriving Alternative

Jake McArthur jake.mcarthur at gmail.com
Thu Oct 15 00:08:11 EDT 2009


Martijn van Steenbergen wrote:
> It doesn't work for this one:
> 
>> newtype Split a = Split { runSplit :: [Either a (Char, Split a) ]}
> 
> But my handwritten instance remains identical.

The instance has the form [], not the form [Either _ (Char, Split _)]. 
Since they don't match exactly, it won't give you an instance 
automagically. It could have been the case that you intended some other 
instance besides []'s. All generalized newtype deriving does is derive 
instances for newtypes that wrap exactly what the instance is defined over.

- Jake


More information about the Haskell-Cafe mailing list