Background
I am trying to help someone in StackOverflow with a question regarding Futures and Maybes and Eithers. My first approach is to have a simple function that takes in a Maybe
and computes something.
Code
I am using Sanctuary, but this is equivalent to Ramda or any other library.
const S = require("sanctuary");
const transform = S.map(
S.pipe( [ S.trim, S.toUpper ] )
);
S.Maybe.Just( [" heello", " world!"] )
.map( transform )
Problem
The problem is that this simple function is failing with the error:
TypeError: S.Maybe.Just(...).map is not a function
Question
I am confused to say the least. I know that Maybe is a Monad, and that Monads are Functors. Each Functor must have a map
method, but somehow Maybe.Just ( which is a Maybe type ) doesn't?
What am I doing wrong?
Maybe
is a functor and has afantasy-land/map
attached, and it's consumed usingS.map
. Also, you build aJust
usingS.Just
orS.of (S.Maybe)
: