[Haskell-cafe] deriving ListLike instance

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Jul 26 00:14:05 CEST 2011


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

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



More information about the Haskell-Cafe mailing list