[Haskell-cafe] Byte Histogram
John Lato
jwlato at gmail.com
Tue Feb 8 13:41:11 CET 2011
On Tue, Feb 8, 2011 at 12:33 PM, Ivan Lazar Miljenovic <
ivan.miljenovic at gmail.com> wrote:
> On 8 February 2011 23:25, John Lato <jwlato at gmail.com> wrote:
> >> class Container c where
> >> type Elem c :: *
> >>
> >> class (Container cIn, Container cOut) => CMap cIn cOut where
> >> cmap :: (Elem cIn -> Elem cOut) -> cIn -> cOut
> >>
> >> instance (a ~ Elem (c a), b ~ Elem (c b), Functor c, Container (c a),
> >> Container (c b)) => CMap (c a) (c b) where
> >> cmap = fmap
>
> I'm not sure if that will work for types like Set, as you're not
> explicitly bringing the constraint in.
It won't work for Set, but Set's not a functor. In this case just write
this instance instead:
> instance (Ord a, Ord b) => CMap (Set a) (Set b) where
> cmap = Set.map
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110208/bf5758d5/attachment.htm>
More information about the Haskell-Cafe
mailing list