Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  What is wrong with my types signatures. (PICCA Frederic-Emmanuel)


----------------------------------------------------------------------

Message: 1
Date: Mon, 23 Jan 2017 08:48:26 +0000
From: PICCA Frederic-Emmanuel
        <frederic-emmanuel.pi...@synchrotron-soleil.fr>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell" <beginners@haskell.org>
Subject: [Haskell-beginners] What is wrong with my types signatures.
Message-ID:
        
<a2a20ec3b8560d408356cac2fc148e53bb32a...@sun-dag3.synchrotron-soleil.fr>
        
Content-Type: text/plain; charset="us-ascii"

Hello here a snipset code

class Shape sh => FrameND t sh where
  shapeND :: t -> MaybeT IO sh
  rowND :: t -> sh -> MaybeT IO (XrdMeshFrame sh)

I have an instance of FrameND

then I created a function which use this class

framesND :: (Shape sh, FrameND a sh) => Pipe a (XrdMeshFrame sh) IO ()
framesND = do
  d <- await
  sh' <- lift $ runMaybeT $ shapeND d
  let n = size sh'
  forM_ [0..n-1] (\i' -> do
                     f <- lift $ runMaybeT $ rowND d (fromIndex sh' i')
                     when (isJust f) (yield (fromJust f)))

But when I compile it; I get this error message


src/Hkl/XRD.hs:613:55:
    Could not deduce (sh ~ Maybe a0)
    from the context (Shape sh, FrameND a sh)
      bound by the type signature for
                 framesND :: (Shape sh, FrameND a sh) =>
                             Pipe a (XrdMeshFrame sh) IO ()
      at src/Hkl/XRD.hs:606:13-70
      `sh' is a rigid type variable bound by
           the type signature for
             framesND :: (Shape sh, FrameND a sh) =>
                         Pipe a (XrdMeshFrame sh) IO ()
           at src/Hkl/XRD.hs:606:13
    Expected type: Maybe (XrdMeshFrame sh)
      Actual type: Maybe (XrdMeshFrame (Maybe a0))
    In the first argument of `fromJust', namely `f'
    In the first argument of `yield', namely `(fromJust f)'
    In the second argument of `when', namely `(yield (fromJust f))'


So I do not undestand why the typse system guess Maybe a0 instead of sh in f

If I read this

f <- lift $ runMaybeT $ rowND d (fromIndex sh' i')

runMaybeT return a (Maybe (XrdMeshFrame sh)) and then I lift it into the Pipe.

So

What is wrong ?

thanks


Frederic


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 103, Issue 18
******************************************

Reply via email to