Re:Railway-oriented programming
by gamegoblin on Friday June 13, 2014 @03:12AM
(#7887721)
The 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.
Re:Railway-oriented programming
by thinkpad20 on Friday June 13, 2014 @10:21AM
(#7888958)
I 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...).
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...