[Haskell-cafe] Is there Functor instance of Enumerator'

3 views
Skip to first unread message

yi huang

unread,
Jul 1, 2011, 10:38:06 AM7/1/11
to haskel...@haskell.org
Say i want to compose Enumerator ByteString m b and Iteratee Builder
m b, so I try to transform the enum to Enumerator Builder m b,
providing function ByteString -> Builder. It's like implement a
Functor instance for Enumerator. But i failed, there are no way to
make type system happy.
Am I right that there is no Functor instance of Enumerator?

--
http://www.yi-programmer.com/blog/

_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Alexander Solla

unread,
Jul 1, 2011, 1:44:46 PM7/1/11
to yi huang, Haskell Cafe
On Fri, Jul 1, 2011 at 7:38 AM, yi huang <yi.cod...@gmail.com> wrote:
Say i want to compose  Enumerator ByteString m b and Iteratee Builder
m b, so I try to transform the enum to Enumerator Builder m b,
providing function ByteString -> Builder. It's like implement a
Functor instance for Enumerator. But i failed, there are no way to
make type system happy.
Am I right that there is no Functor instance of Enumerator?

I'm pretty sure there is one, but it's a functor over b.  So something like:

instance Functor (Enumerator a m) 

I think you want to use an Enumeratee:

enumerateeByteStringBuilder :: Enumeratee ByteString Builder m b

Check out map :: (a -> b) -> Enumeratee a b m c

Reply all
Reply to author
Forward
0 new messages