[Haskell-beginners] howto Pipe
PICCA Frederic-Emmanuel
frederic-emmanuel.picca at synchrotron-soleil.fr
Thu Feb 18 14:57:50 UTC 2016
Hello
I try to mix my C library and the Pipe module
here the code I am using
solveTraj :: Factory -> Geometry -> Detector -> Sample -> Pipe Engine Geometry IO ()
solveTraj f g d s = do
e <- await
let name = engineName e
withSample s $ \sample ->
withDetector d $ \detector ->
withGeometry f g $ \geometry ->
withEngineList f $ \engines ->
withCString name $ \cname -> do
c_hkl_engine_list_init engines geometry detector sample
engine <- c_hkl_engine_list_engine_get_by_name engines cname nullPtr
n <- c_hkl_engine_pseudo_axis_names_get engine >>= darrayStringLen
yield $ solve' engine n e >>= getSolution0
where
getSolution0 :: ForeignPtr HklGeometryList -> IO Geometry
And I am using this like this
runEffect $ for (each engines) >-> solveTraj factory geometry detector sample >-> P.print
where
[Engine]
engines
But When I compile the code I get this error.
src/Hkl/C.hsc:83:3:
Couldn't match type `IO' with `Proxy () Engine () Geometry IO'
Expected type: Proxy () Engine () Geometry IO ()
Actual type: IO ()
In a stmt of a 'do' block:
withSample s
$ \ sample
-> withDetector d
$ \ detector -> withGeometry f g $ \ geometry -> ...
In the expression:
do { e <- await;
let name = engineName e;
withSample s $ \ sample -> withDetector d $ \ detector -> ... }
In an equation for `solveTraj':
solveTraj f g d s
= do { e <- await;
let name = ...;
withSample s $ \ sample -> withDetector d $ ... }
src/Hkl/C.hsc:91:19:
Couldn't match type `Proxy x'0 x0 () (IO Geometry) m0' with `IO'
Expected type: IO ()
Actual type: Proxy x'0 x0 () (IO Geometry) m0 ()
In a stmt of a 'do' block:
yield $ solve' engine n e >>= getSolution0
In the expression:
do { c_hkl_engine_list_init engines geometry detector sample;
engine <- c_hkl_engine_list_engine_get_by_name
engines cname nullPtr;
n <- c_hkl_engine_pseudo_axis_names_get engine >>= darrayStringLen;
yield $ solve' engine n e >>= getSolution0 }
In the second argument of `($)', namely
`\ cname
-> do { c_hkl_engine_list_init engines geometry detector sample;
engine <- c_hkl_engine_list_engine_get_by_name
engines cname nullPtr;
.... }'
I do not understand why the yield does not produce the right type as output.
I think I missed something big :), but...
Thanks for your help
Fred
More information about the Beginners
mailing list