Re: [Haskell-beginners] understanding function signature alignement

Thanks, it is still a bit fuzzy to me ...
I understand what you did but what confuses me is that when i look at function with signature like f :: Monad m => c -> m d I always think that return type is somehow restricted in comparison to input because it demands that output type is wraped inside something (monad in this case). For such signature to fit id signature (a -> a) , c type shoud be also wraped inside monad but it is not case here... Anyhow, I still have to figure it out thanks

You're right that the return type is more restricted than the argument, but
it's in an *absolute* sense, not a relative one. It's not possible to relax
`m d` to make it the same type as `c`, but it IS possible to constrain `c`
to be the same as `m d`! And that's how `id` works here: the input in this
case is known to be the same type as the output. You need something wrapped
in a monad, and you already have that, so you just use it as-is.
On Thu, Aug 9, 2018, 7:22 AM simkestuff@gmail.com
Thanks, it is still a bit fuzzy to me ...
I understand what you did but what confuses me is that when i look at function with signature like
f :: Monad m => c -> m d
I always think that return type is somehow restricted in comparison to input because it demands that output type is wraped inside something (monad in this case).
For such signature to fit id signature (a -> a) , c type shoud be also wraped inside monad but it is not case here...
Anyhow, I still have to figure it out
thanks _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Yes, thinking it the terms that something which is absolutely free to be
whatever, can be restricted and reduced into something else while other way
around is not possible is usefull;
thanks
On Fri, Aug 10, 2018 at 12:06 PM Theodore Lief Gannon
You're right that the return type is more restricted than the argument, but it's in an *absolute* sense, not a relative one. It's not possible to relax `m d` to make it the same type as `c`, but it IS possible to constrain `c` to be the same as `m d`! And that's how `id` works here: the input in this case is known to be the same type as the output. You need something wrapped in a monad, and you already have that, so you just use it as-is.
On Thu, Aug 9, 2018, 7:22 AM simkestuff@gmail.com
wrote: Thanks, it is still a bit fuzzy to me ...
I understand what you did but what confuses me is that when i look at function with signature like
f :: Monad m => c -> m d
I always think that return type is somehow restricted in comparison to input because it demands that output type is wraped inside something (monad in this case).
For such signature to fit id signature (a -> a) , c type shoud be also wraped inside monad but it is not case here...
Anyhow, I still have to figure it out
thanks _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
simkestuff@gmail.com
-
Theodore Lief Gannon