[Haskell-beginners] Conduit composition

Brandon Allbery allbery.b at gmail.com
Wed Apr 10 00:42:11 CEST 2013


On Tue, Apr 9, 2013 at 6:34 PM, Ovidiu D <ovidiudeac at gmail.com> wrote:

> I would expect the following to work as well:
> main =
>     Conduit.sourceList [1..14]
>     $= Conduit.map show
>     $= display
>     $$ Conduit.sinkNull
>
> display = Conduit.iterM putStrLn $= Conduit.iterM putStrLn
>
> ...but I get the compilation error:
> Couldn't match expected type `String' with actual type `()'
>     Expected type: Conduit.Conduit String m0 a0
>       Actual type: Conduit.Source IO ()
>     In the second argument of `($=)', namely `display'
>     In the first argument of `($$)', namely
>       `Conduit.sourceList [1 .. 14] $= Conduit.map show $= display'
>

This looks to me like the monomorphism restriction kicked in and extended
defaulting is turned on, so () got inferred? If so, {-# LANGUAGE
NoMonomorphismRestriction #-} at the top of the file should help.

(If this is actually in ghci, then that is almost certainly what happened;
many people shut off the monomorphism restriction in ghci to avoid this
annoyance.)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130409/dd255c95/attachment.htm>


More information about the Beginners mailing list