[Haskell-cafe] deriving ListLike instance
bob zhang
bobzhang1988 at gmail.com
Tue Jul 26 00:24:31 CEST 2011
Thanks. I know we can only derive built-in classes.
Since Stream is just a newtype and
ListLike [a] a is an instance, so I hope ListLike (Stream a) a would
work given extensions.
Unforturnately, newtype derivation requires the _last_ type variable to
be newtype
Thank you
于 11-7-25 下午6:14, Ivan Lazar Miljenovic 写道:
> On 26 July 2011 04:30, bob zhang<bobzhang1988 at gmail.com> wrote:
>> Hi, all,
>> newtype Stream a = Stream [a]
>>
>> I wanna derive ListLike [a] a automatically, but did not find a solution,
>> I tried
>> deriving instance ListLile (Stream a) a -- does not work
> You can only derive certain in-built classes (Eq, Ord, Show, etc.) and
> - with extensions - some other classes (e.g. Functor). You _cannot_
> derive ListLike. That said, it may be possible to extend either
> derive [1] or DrIFT [2] to be able to generate these instances for
> you.
>
> [1]: http://hackage.haskell.org/package/derive
> [2]: http://hackage.haskell.org/package/DrIFT-cabalized
>
More information about the Haskell-Cafe
mailing list