strange error inside a case

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

strange error inside a case

PICCA Frederic-Emmanuel
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
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: strange error inside a case

Sylvain Henry-2
Hello,

What is the type of hdf2mergedcbf' ?

Does it work if you write `void (hdf2mergedcbf' (head masters) 1 1)` ?


On 29/11/2019 11:55, PICCA Frederic-Emmanuel wrote:

> 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
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: strange error inside a case

PICCA Frederic-Emmanuel
> What is the type of hdf2mergedcbf' ?

hdf2mergedcbf' :: Path Abs File -> Int -> Int -> IO ()

> Does it work if you write `void (hdf2mergedcbf' (head masters) 1 1)` ?

nop

    • In the expression: void (hdf2mergedcbf' (head masters) 1 1)
      In a case alternative:
          (SomeDataCollection SCollect SHdf5 _)
            -> void (hdf2mergedcbf' (head masters) 1 1)
      In the second argument of ‘($)’, namely
        ‘case col of {
           (SomeDataCollection SCollect SHdf5 _)
             -> void (hdf2mergedcbf' (head masters) 1 1) }’
    |
184 |         (SomeDataCollection SCollect SHdf5 _)          -> void (hdf2mergedcbf' (head masters) 1 1)
    |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

HsCompilation exited abnormally with code 1 at Fri Nov 29 19:23:04
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners