[Haskell-beginners] strange error inside a case

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Nov 29 10:55:35 UTC 2019


Hello, I aheve some code whcih look like this

thumbnail' :: (MonadIO m, MonadReader Beamline m, MonadThrow m) => ThumbnailInput -> m ()
thumbnail' (ThumbnailInput col) = do
  cwd <- toResultsPath "thumbnail" col
  let shakeFiles' =  cwd </> $(mkRelDir ".shake/")
  let shakeReport' = shakeFiles' </> $(mkRelFile "report.html")

  liftIO $ shake shakeOptions{ shakeFiles=fromAbsDir shakeFiles'
                             , shakeReport=[fromAbsFile shakeReport']
                             , shakeVerbosity=Diagnostic
                             } $ do
    let uploaded = fromAbsFile $ cwd </> $(mkRelFile "thumbnail.uploaded")

    want [uploaded]

    -- (Rule 1) merge the image files
    uploaded %> \_out -> do
      -- need [xml]
      masters <- liftIO $ expectedInputFiles col
      liftIO $ hdf2mergedcbf' (head masters) 1 1 
      liftIO $ case col of
        (SomeDataCollection SCollect SHdf5 _)          -> hdf2mergedcbf' (head masters) 1 1
        (SomeDataCollection SCollect SHdf5' _)         -> undefined -- hdf2mergedcbf' (head masters) 1 1
        (SomeDataCollection SCaracterization SHdf5 _)  -> undefined
        (SomeDataCollection SCaracterization SHdf5' _) -> undefined
        _                                              -> error "show not arrive here !!!"

      -- hdf2mergedcbf
      -- command [] "touch" [uploaded]
      return ()


When I try to compile it, it give me this error

    • Couldn't match type ‘a0’ with ‘()’
        ‘a0’ is untouchable
          inside the constraints: f ~ 'ISPyB.DataCollection.Hdf5
          bound by a pattern with constructor:
                     SHdf5 :: SCollectSourceFormat 'ISPyB.DataCollection.Hdf5,
                   in a case alternative
          at src/Thumbnail.hs:180:38-42
      Expected type: IO a0
        Actual type: IO ()
    • In the expression: hdf2mergedcbf' (head masters) 1 1
      In a case alternative:
          (SomeDataCollection SCollect SHdf5 _)
            -> hdf2mergedcbf' (head masters) 1 1
      In the second argument of ‘($)’, namely
        ‘case col of
           (SomeDataCollection SCollect SHdf5 _)
             -> hdf2mergedcbf' (head masters) 1 1
           (SomeDataCollection SCollect SHdf5' _) -> undefined
           (SomeDataCollection SCaracterization SHdf5 _) -> undefined
           (SomeDataCollection SCaracterization SHdf5' _) -> undefined
           _ -> error "show not arrive here !!!"’
    |
180 |         (SomeDataCollection SCollect SHdf5 _)          -> hdf2mergedcbf' (head masters) 1 1
    |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


What I do not understand is how to fix this since it seems that

  liftIO $ hdf2mergedcbf' (head masters) 1 1  works out of the case

thanks for your help

Frederic


More information about the Beginners mailing list