Extend Documentation Issue
i-am-tom opened this issue · comments
https://github.com/purescript/purescript-either/blob/master/src/Data/Either.purs#L161
Forgive me if I'm totally wrong (sorry!), but I think that line should be:
f <<= Right x = Right (f (Right x))
I know it's a relatively minor thing, but this issue is more to cement my understanding of the Extend class... Thanks!
It's right as it is actually, even though it may not appear so from the implementation!
extend ∷ ∀ w a b. Extend w ⇒ (w a → b) → w a → w b
extend ∷ ∀ a b. (Either e a → b) → Either e a → Either e b
Note how f
expects an Either e a
but returns a b
. That's why we pass x
(which is Right a
) through without pattern matching on it. f
then returns a value of b
unwrapped, so we then re-wrap it to produce a Right b
result.
I see, though wouldn't f <<= Right x = Right (f x)
suggest that x
is the value within the Right
? Sorry, I'm probably missing something obvious!
Hah, sorry, yes you are absolutely right after all.
Fixed in #22 at long last - closing :)