Is coffeescript `? .` a monad operator?

I just read about Maybe Monad in Haskell and it looks like the role of Coffeescript ?.. Is the operator ?.considered a monad or are these just two different ways to do the same thing?

In Haskell, you write

a >>= b >>= c

In coffeescript you write

a?.b?.c
+4
source share
3 answers

One operator cannot be a monad just as an engine cannot be a car. Short-circuited behavior is a Maybe property and (Maybe, return, (>>=))turns out to be a monad.

, , CoffeeScript, , ?. bind. Haskell, .

+9

( → =) Maybe, . , return bind ( return, fmap join) .

. . .

+2

?. ?

, CoffeeScript ?. , . - , : , .

; , , - , . IO , Haskell; , , , IO . , ; , , , .

" X L ( ) ?" . - " " . X, . , " " , - , " " , ( ) , .

sequence; m [m a] m [a]. Maybe, , , [Maybe a] - Maybe [a] - - Nothing, Nothing, . ?. () , , , , , , ? sequence , . - -, , . .. ..

- . , , , , , . Haskell , , - sequence :: Monad m => [m a] -> m [a]. , sequence , , . !

" " , , . , ?. CoffeeScript ( , , CoffeeScript , ), . , , , : " , ?.?

+1

Source: https://habr.com/ru/post/1542096/


All Articles