Joerg Fritsch | 27 Jul 13:05 2013

casting a into Maybe a

If I have the following type signature 
transMit :: Serialize a => Socket -> POSIXTime -> KEY -> Maybe a -> TPSQ -> TMap a -> IO ()

And the function is called with
transMit s now key newmsgs q m 
where newmsgs is whatever type a I get but _not_ a Maybe a

then I get the error 
Could not deduce (a ~ Maybe a)
from the context (Serialize a)

Can I somehow when I call transmit cast newmsgs into a Maybe newmsgs or so so that the function call fits the
type signature? 

--Joerg
Niklas Hamb├╝chen | 27 Jul 13:42 2013

Re: casting a into Maybe a

Put a Just around it?

transMit s now key (Just newmsgs) q m

On Sat 27 Jul 2013 20:05:43 JST, Joerg Fritsch wrote:
> If I have the following type signature
> transMit :: Serialize a => Socket -> POSIXTime -> KEY -> Maybe a -> TPSQ -> TMap a -> IO ()
>
>
> And the function is called with
> transMit s now key newmsgs q m
> where newmsgs is whatever type a I get but _not_ a Maybe a
>
> then I get the error
> Could not deduce (a ~ Maybe a)
> from the context (Serialize a)
>
> Can I somehow when I call transmit cast newmsgs into a Maybe newmsgs or so so that the function call fits the
type signature?
>
> --Joerg
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane