<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">Hello,<br><br>I presume these `c_hkl_<something>` return `IO`? Then you need to `lift` them into `Pipe` (well, `Proxy`).<br><br>Best regards,<br>Marcin Mrotek</div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Od: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:frederic-emmanuel.picca@synchrotron-soleil.fr">PICCA Frederic-Emmanuel</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Wysłano: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">2016-02-18 15:58</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Do: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:beginners@haskell.org">beginners@haskell.org</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Temat: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">[Haskell-beginners] howto Pipe</span><br><br></div>Hello<br><br>I try to mix my C library and the Pipe module<br><br>here the code I am using<br><br>solveTraj :: Factory -> Geometry -> Detector -> Sample -> Pipe Engine Geometry IO ()<br>solveTraj f g d s = do<br> e <- await<br> let name = engineName e<br> withSample s $ \sample -><br> withDetector d $ \detector -><br> withGeometry f g $ \geometry -><br> withEngineList f $ \engines -><br> withCString name $ \cname -> do<br> c_hkl_engine_list_init engines geometry detector sample<br> engine <- c_hkl_engine_list_engine_get_by_name engines cname nullPtr<br> n <- c_hkl_engine_pseudo_axis_names_get engine >>= darrayStringLen<br> yield $ solve' engine n e >>= getSolution0<br><br>where <br><br> getSolution0 :: ForeignPtr HklGeometryList -> IO Geometry<br><br>And I am using this like this<br><br>runEffect $ for (each engines) >-> solveTraj factory geometry detector sample >-> P.print<br><br>where<br><br>[Engine]<br>engines<br><br><br>But When I compile the code I get this error.<br><br>src/Hkl/C.hsc:83:3:<br> Couldn't match type `IO' with `Proxy () Engine () Geometry IO'<br> Expected type: Proxy () Engine () Geometry IO ()<br> Actual type: IO ()<br> In a stmt of a 'do' block:<br> withSample s<br> $ \ sample<br> -> withDetector d<br> $ \ detector -> withGeometry f g $ \ geometry -> ...<br> In the expression:<br> do { e <- await;<br> let name = engineName e;<br> withSample s $ \ sample -> withDetector d $ \ detector -> ... }<br> In an equation for `solveTraj':<br> solveTraj f g d s<br> = do { e <- await;<br> let name = ...;<br> withSample s $ \ sample -> withDetector d $ ... }<br><br>src/Hkl/C.hsc:91:19:<br> Couldn't match type `Proxy x'0 x0 () (IO Geometry) m0' with `IO'<br> Expected type: IO ()<br> Actual type: Proxy x'0 x0 () (IO Geometry) m0 ()<br> In a stmt of a 'do' block:<br> yield $ solve' engine n e >>= getSolution0<br> In the expression:<br> do { c_hkl_engine_list_init engines geometry detector sample;<br> engine <- c_hkl_engine_list_engine_get_by_name<br> engines cname nullPtr;<br> n <- c_hkl_engine_pseudo_axis_names_get engine >>= darrayStringLen;<br> yield $ solve' engine n e >>= getSolution0 }<br> In the second argument of `($)', namely<br> `\ cname<br> -> do { c_hkl_engine_list_init engines geometry detector sample;<br> engine <- c_hkl_engine_list_engine_get_by_name<br> engines cname nullPtr;<br> .... }'<br><br><br>I do not understand why the yield does not produce the right type as output.<br><br>I think I missed something big :), but...<br><br>Thanks for your help<br><br>Fred<br>_______________________________________________<br>Beginners mailing list<br>Beginners@haskell.org<br>http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners<br></body></html>