<div dir="ltr"><div><div><div>Yield in your producer is of type DataFrameHkI3D -> Producer DataFrameHkl3D IO ()<br><br></div>But you are putting an (IO DataFrameHkI3D) in as an argument.<br><br></div>You should be able to do something like this:<br><br>getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO ()<br>getDataFrameHkl3D d = do<br> n <- lift $ hkl_h5_len (h5mu d)<br> frames <- forM [0..n] $ \i -> lift (getDataFrameHkl3D' d i) -- :: Producer DataFrameHkl3D IO [DataFrameHkl3D]<br> forM_ frames yield<br><br></div><div>I have a feeling it may be more efficient to yield immediately on each loop as such:<br><br>getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO ()<br>getDataFrameHkl3D d = do<br> n <- lift $ hkl_h5_len (h5mu d)<br> forM_ [0..n] (\i -> lift (getDataFrameHkl3D' d i) >>= yield)<br><br></div><div>You may also substitutde liftIO for lift, if you wish.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 22, 2016 at 12:37 PM, PICCA Frederic-Emmanuel <span dir="ltr"><<a href="mailto:frederic-emmanuel.picca@synchrotron-soleil.fr" target="_blank">frederic-emmanuel.picca@synchrotron-soleil.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Still playing with the Pipe module<br>
<br>
here the code I try to write<br>
<br>
getDataFrameHkl3D' :: DataFrameHkl3DH5SixsUhv -> Int -> IO DataFrameHkl3D<br>
getDataFrameHkl3D' d i = do<br>
positions <- get_position (h5mu d) i<br>
return $ DataFrameHkl3D { df_n = i<br>
, df_image = positions<br>
}<br>
<br>
getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO ()<br>
getDataFrameHkl3D d = do<br>
n <- lift $ hkl_h5_len (h5mu d)<br>
forM_ [0..n] $ \i -> yield $ getDataFrameHkl3D' d i<br>
<br>
<br>
but when I compile it I get this error message<br>
<br>
src/hkl3d.hs:274:3:<br>
Couldn't match type `IO DataFrameHkl3D' with `DataFrameHkl3D'<br>
Expected type: Proxy X () () DataFrameHkl3D IO ()<br>
Actual type: Proxy X () () (IO DataFrameHkl3D) IO ()<br>
In a stmt of a 'do' block:<br>
forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i<br>
In the expression:<br>
do { n <- lift $ hkl_h5_len (h5mu d);<br>
forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i }<br>
In an equation for `getDataFrameHkl3D':<br>
getDataFrameHkl3D d<br>
= do { n <- lift $ hkl_h5_len (h5mu d);<br>
forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i }<br>
<br>
I do not know how to fix my code...<br>
<br>
Frederic<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>