[Haskell-beginners] pipe and IO

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Tue Mar 22 16:37:04 UTC 2016


Hello,

Still playing with the Pipe module

here the code I try to write

getDataFrameHkl3D' ::  DataFrameHkl3DH5SixsUhv -> Int -> IO DataFrameHkl3D
getDataFrameHkl3D' d i = do
  positions <- get_position (h5mu d) i
  return $ DataFrameHkl3D { df_n = i
                          , df_image = positions
                          }
                       
getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO ()
getDataFrameHkl3D d = do
  n <- lift $ hkl_h5_len (h5mu d)
  forM_ [0..n] $ \i -> yield $ getDataFrameHkl3D' d i


but when I compile it I get this error message

src/hkl3d.hs:274:3:
    Couldn't match type `IO DataFrameHkl3D' with `DataFrameHkl3D'
    Expected type: Proxy X () () DataFrameHkl3D IO ()
      Actual type: Proxy X () () (IO DataFrameHkl3D) IO ()
    In a stmt of a 'do' block:
      forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i
    In the expression:
      do { n <- lift $ hkl_h5_len (h5mu d);
           forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i }
    In an equation for `getDataFrameHkl3D':
        getDataFrameHkl3D d
          = do { n <- lift $ hkl_h5_len (h5mu d);
                 forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i }

I do not know how to fix my code...

Frederic


More information about the Beginners mailing list