Monadic Implementation Quirks
Monadics

Prev:Monads


Implementations of fmap, reify, and and-then are all built around the lazy-call combinator. This combinator emulates the behavior of lazily evaluated languages like Haskell by currying input over a quotation until it's type signature matches ( -- x ) . As such, any input functions to these functions must eventually resolve to a single output.
USING: arrays math.quadratic monadics quotations prettyprint ; ! Unevaluated ( -- x x ) quotation will remain thunked. [ quadratic ] 1 just <$> 0 just <*> -1 just <*> .
T{ Just { value [ -1 0 1 3 nreverse quadratic ] } }

This is easy to fix using a word like 2array.
USING: arrays math.quadratic monadics quotations prettyprint ; ! Computes result into Maybe value as expected. [ quadratic 2array ] 1 just <$> 0 just <*> -1 just <*> .
T{ Just { value { 1.0 -1.0 } } }