I'm working through a tutorial on functional programming that shows the following code example using the sanctuary.js library:
var S = require('sanctuary')
var Maybe = S.Maybe
S.add(
Maybe.of(3)
,Maybe.of(5)
)
.map(n => n * n)
I get the error Maybe.of is not a function
. The sanctuary.js API documentation shows an example of using .of
as S.of(S.Maybe, 42)
, so I modified my code like this:
...
S.of(S.Maybe, 3)
,S.of(S.Maybe, 5)
And I get the error:
add :: FiniteNumber -> FiniteNumber -> FiniteNumber
^^^^^^^^^^^^
1
The value at position 1 is not a member of ‘FiniteNumber’.
I don't see any documentation on the sanctuary site about the FiniteNumber type class. How do I make this code work? And is there any way to chain the sanctuary .of
constructor onto type classes, so the example on the tutorial site works?
TypeError: Maybe.of is not a function
" with your first example? I've addedlet Maybe = S.Maybe
to prevent a reference error when usingMaybe
, but how do I get it to allow me to chain the sanctuaryof
constructor ontoMaybe
as in your example? – Symbolism