Hello Conrad,<br><br><br>Thanks for taking the time to answer back. Actually I don't want to do anything fancy, I just want to compose a list of Enumeratees together into an Enumerator, using the same type for both <span style="font-family: courier new,monospace;">ao</span> and <span style="font-family: courier new,monospace;">ai</span>, I suspect it doesn't matter what the type of this ao and ai are, I would obtain the same error using this simpler example:<br>
<br><span style="font-family: courier new,monospace;">module Main where<br><br>import Data.List (foldl')<br>import Data.Enumerator hiding (foldl')<br>import qualified Data.Enumerator.List as EL<br><br>-- This is what I orginally have<br>
main :: IO ()<br>main = run_ (((enumList 5 [1..] $=<br> EL.isolate 100) $=<br> EL.filter ((== 0) . (`mod` 2))) $$<br> EL.consume) >>= <br> print <br> <br>
-- This is what I want and for some reason is not <br>-- compiling (infinite type error)<br>--main2 :: IO ()<br>--main2 = run (enum $$ EL.consume) >>= print<br>-- where<br>-- enum = foldl' ($=) <br>-- (enumList 5 [1..]) <br>
-- [ EL.isolate 100<br>-- , EL.filter ((==0) . (`mod` 2))<br>-- ]<br></span><br><br><br>For some complicated type logic, main2 won't compile, I'm trying to figure out a way to actually do this. The reason why I want to do the composition through list is because I'm mapping input parameters (from System.Environment.getArgs) to a list of Enumeratees, and I want to compose them dynamically.<br>
<br>Hope this helps.<br><br>Roman.- <br><br><div class="gmail_quote">2011/10/3 Conrad Parker <span dir="ltr"><<a href="mailto:conrad@metadecks.org">conrad@metadecks.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2011/10/4 Román González <<a href="mailto:romanandreg@gmail.com">romanandreg@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hey guys,<br>
><br>
> Right now I'm facing with a type problem that is really nasty, I want to<br>
> compose a list of enumeratees using the ($=) operator to create a new<br>
> enumerator. Whenever I'm trying to use the foldx function in conjunction<br>
> with ($=) I get this error:<br>
><br>
>> :t foldr ($=)<br>
><br>
> <interactive>:1:7:<br>
> Occurs check: cannot construct the infinite type:<br>
> b0 = Step ao0 m0 b0<br>
> Expected type: Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> Actual type: Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> -> Enumerator ao0 m0 b0<br>
> In the first argument of `foldr', namely `($=)'<br>
> In the expression: foldr ($=)<br>
><br>
>> :t Prelude.foldl ($=)<br>
><br>
> <interactive>:1:15:<br>
> Occurs check: cannot construct the infinite type:<br>
> b0 = Step ao0 m0 b0<br>
> Expected type: Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> -> Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> Actual type: Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> -> Enumerator ao0 m0 b0<br>
> In the first argument of `Prelude.foldl', namely `($=)'<br>
> In the expression: Prelude.foldl ($=)<br>
><br>
> <interactive>:1:15:<br>
> Occurs check: cannot construct the infinite type:<br>
> b0 = Step ao0 m0 b0<br>
> Expected type: Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> -> Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> Actual type: Enumerator ao0 m0 (Step ao0 m0 b0)<br>
> -> Enumeratee ao0 ao0 m0 b0<br>
> -> Enumerator ao0 m0 b0<br>
> In the first argument of `Prelude.foldl', namely `($=)'<br>
> In the expression: Prelude.foldl ($=)<br>
><br>
> Obviously there is something I don't quite understand about the ($=) (=$)<br>
> functions, how can one compose a list of enumeratees, is it even possible?<br>
<br>
</div></div>Hi,<br>
<br>
what are you trying to actually do, ie. what kind of data are you<br>
trying to transform, what are the inputs and outputs of each<br>
enumeratee?<br>
<br>
are you trying to feed the output of the first enumeratee into the<br>
input of the second, and so on? or are you trying to run them all in<br>
parallel?<br>
<font color="#888888"><br>
Conrad.<br>
</font></blockquote></div><br>