[Haskell-beginners] Conduit composition

Ovidiu D ovidiudeac at gmail.com
Wed Apr 10 00:34:40 CEST 2013


Given the following works as expected (i.e. prints the value twice):

main =
    Conduit.sourceList [1..14]
    $= Conduit.map show
    $= Conduit.iterM putStrLn
    $= Conduit.iterM putStrLn
    $$ Conduit.sinkNull

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'

I don't understand why the type of display is inferred to a Conduit.Source.
Can somebody please explain?

What I want is to have readable names for certain segments in my pipe. Is
that possible?

Thanks,
ovidiu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130410/27069046/attachment.htm>


More information about the Beginners mailing list