newEmptyMVar return type

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

newEmptyMVar return type

Velichko Lefterov
Hello,
could someone explain me simple how return-type polymorphism works
in the following case:
newEmptyMVar :: IO (MVar a) ?

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

Re: newEmptyMVar return type

Velichko Lefterov
OK,
I tried this one:

test:: IO (Maybe a)
test = return Nothing

It looks similar and it seems to work...

On Tue, Jan 5, 2021 at 8:22 PM Velichko Lefterov <[hidden email]> wrote:
Hello,
could someone explain me simple how return-type polymorphism works
in the following case:
newEmptyMVar :: IO (MVar a) ?

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

Re: newEmptyMVar return type

David McBride
It means that the function can return an mvar containing any type that you need. What type it returns depends on what type your program asks for.

On Wed, Jan 6, 2021, 01:37 Velichko Lefterov <[hidden email]> wrote:
OK,
I tried this one:

test:: IO (Maybe a)
test = return Nothing

It looks similar and it seems to work...

On Tue, Jan 5, 2021 at 8:22 PM Velichko Lefterov <[hidden email]> wrote:
Hello,
could someone explain me simple how return-type polymorphism works
in the following case:
newEmptyMVar :: IO (MVar a) ?
_______________________________________________
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