Before raising my grasp (and I've still a lot to understand and learn) of monads, I was always confused by return monadic operation.
For what I understand now the return operation (called sometime unit if I'm not wrong) inject a value into the monadic abstraction.
In fact, in Haskell the Control.Monad type class defines return with this signature return :: a -> m a.
In FSharp that lacks HKT:
type Maybe = Just x | Nothing
module Maybe =
return x = Just x
// ...
we must define everything for each specific monad. Unless creating a strange convoluted and not idiomatic implementations, I guess...
So also if returnOrFail sense is clear it's name doesn't clash with this concept? It's not better something like getOrFail? (E.g.: I'm agree to a more domain specific return like Succeed and FailWith.
I know that computations expressions have a ReturnFrom for allowing a wrapped value escape the monad, and in fact now I found it confusing...
I'm not here to criticize, just to hear thoughs and learn more about the subject. If I wouldn't like this library, I'd never ported it to C# for direct source inclusion as annunced in issue #25 (library that still need refinements and comments...).
Before raising my grasp (and I've still a lot to understand and learn) of monads, I was always confused by
return
monadic operation.For what I understand now the
return
operation (called sometimeunit
if I'm not wrong) inject a value into the monadic abstraction. In fact, in Haskell the Control.Monad type class defines return with this signaturereturn :: a -> m a
. In FSharp that lacks HKT:we must define everything for each specific monad. Unless creating a strange convoluted and not idiomatic implementations, I guess...
So also if returnOrFail sense is clear it's name doesn't clash with this concept? It's not better something like
getOrFail
? (E.g.: I'm agree to a more domain specific return like Succeed and FailWith.I know that computations expressions have a
ReturnFrom
for allowing a wrapped value escape the monad, and in fact now I found it confusing...I'm not here to criticize, just to hear thoughs and learn more about the subject. If I wouldn't like this library, I'd never ported it to C# for direct source inclusion as annunced in issue #25 (library that still need refinements and comments...).
My best regards, Giacomo