3 ms·
Yeah, I thought the same thing, once I saw val bind : ('a -> Result<'b,'c>) -> Result<'a,'c> -> Result<'b,'c> Because that's precisely the signature of bi
by thinkpad20 12y ago
Yeah, I thought the same thing, once I saw
val bind : ('a -> Result<'b,'c>) -> Result<'a,'c> -> Result<'b,'c>
Because that's precisely the signature of bind (=<<) in Haskell. Although it looks nicer in Haskell. :P
But I do respect the author's desire to avoid getting too mathy and hifalutin with the theoretical stuff, because you can really go overboard down that path...
- gamegoblin 12y agoThe corresponding type signature in haskell is bind :: (a -> Either b c) -> Either a c -> Either b c So really you just save yourself a couple of angle brackets. That being said, the author does introduce the (>>=) function, but just doesn't say monad because that can turn people off really quickly.
- nightski 12y agoI'd say it's the quotes that are noisy, not the angle brackets. But it's a minor nitpick, the F# one is fine.
- thinkpad20 12y agoI was slightly mistaken, because I missed how the error type was put last in all of those Results. In Haskell, the error type is typically written first (Either MyError x), because since `Either a` is an instance of monad, we can replace `Either a` with `m` and get bind :: (a -> m b) -> m a -> m b Which is exactly the signature of (=<<). So you don't just get a cleaner syntax; you now have the ability to use `bind` with any monad (Maybe, List, IO, State...).