Fantasy Land compatible types for easy integration with Ramda.
Questions tagged [ramda-fantasy]
15 questions
6
votes
1 answer
Ramda with FP Types
Recently I have decided to switch from lodash to ramda to play with functional way of composing my logic. I love it! After some extensive digging into FP I have found that's it's not only about handy pure/point free utilities (ramda), but more about…

remtsoy
- 465
- 1
- 3
- 15
6
votes
2 answers
Use Fluture with Ramda
I was using Bluebird for doing asynchronous stuff, but now have to do a lot of empty / null / error checks and I don't want to go down the usual if Else route. Am thinking of using monads, but have not yet grokked it completely.
Also I want it to…

jgr0
- 697
- 2
- 6
- 20
5
votes
1 answer
Monadic IO with ramda and ramda-fantasy
Trying to figure out how the IO monad works.
Using the code below I read filenames.txt and use the results to rename files in the directory testfiles. This is obviously unfinished, so instead of actually renaming anything I log to console. :)
My…

rickythefox
- 6,601
- 6
- 40
- 62
2
votes
1 answer
Map over an array wrapped in a Maybe
How do I map over an array wrapped in a Maybe or any other Monad? Right now I'm using
const map2 = curry(
(fn, xs) => map(map(fn))(xs)
)
const data = [1, 2]
pipe(
Maybe,
map2(add(1))
)(data)

jgr0
- 697
- 2
- 6
- 20
2
votes
1 answer
Ramda Pass "Maybe" Error Message Through Chain Calls
Lets say I have bunch of functions returns Just or Nothing values and I want to chain them together like this;
var a = M.Just("5").map(function(data){
return 1;
}).chain(function(data){
/*Make some operation return Just or Nothing */
…

altayseyhan
- 735
- 1
- 7
- 18
1
vote
2 answers
How to execute a function that returns a function inside of IO monad
I am using "Ramda/Fantasy" library for creating Monads. And i am trying to combine IO's to get element from the DOM and change its text content. But the problem is that function that changes content of the element needs to take two arguments…

Djordje Vuckovic
- 383
- 1
- 5
- 11
1
vote
1 answer
Why the third function doesn't get called in a pipeK when all of them are futures?
I can't figure out why the third function (i.e. doStuff3) isn't being called, so the console.log on fork should print "hello world!!!!"
const
doStuff = () => Future.of(["hello", "world"]),
doStuff2 = (x, y) => Future((resolve, reject) =>…

Matías Fidemraizer
- 63,804
- 18
- 124
- 206
0
votes
2 answers
Group objects by name Ramda
Good evening, I need to group an array of objects by their nickname, here I show you the data:
[
{
"nickName": "Info2",
"countNotice": 4
},
{
"nickName": "Info2",
"countAlarm": 1
},
{
"nickName": "Info1",
…

Denis Alayza
- 55
- 7
0
votes
1 answer
Is is possible to chain Maybe in case of null/undefined?
There is a given function, that is fixed and must not be changed:
const validate = v => v === "fred" ? "Y" : undefined
Now, because I would like to be functional and would like to avoid null-checks I've decided to use Maybe (ramda-fantasy) for…

Maciej Miklas
- 3,305
- 4
- 27
- 52
0
votes
1 answer
Reflecting object internals in type signature
I'm diving into FP in js (I'm newbbie to FP) and I faced a little "problem" describing remaining arguments of curried functions, wrapped into Functors
Let's say we have the following curried situation:
const makeApiCallFuture = curry((path, user,…

pandomic
- 607
- 1
- 6
- 17
0
votes
1 answer
How do I take a value out of a Maybe monad in ramda-fantasy?
I want to have a pipe that does some operations on a Maybe, and want to return its value at last. Currently I am doing:
const data = Maybe(5)
pipe(
map(add(1)),
... other operations
y => y.getOrElse([])
)(data)
Is there any cleaner way out?

jgr0
- 697
- 2
- 6
- 20
0
votes
1 answer
How to transfer Either.Right to Either.Left?
db.findUser(id).then(R.pipe(
R.ifElse(firstTestHere, Either.Right, () => Either.Left(err)),
R.map(R.ifElse(secondTestHere, obj => obj, () => Either.Left(err))),
console.log
))
If the first test doesn't pass, it will return Either.Left, and…

qwang07
- 1,136
- 2
- 11
- 20
0
votes
1 answer
RE: Error encountered in ramda-fantasy map method
I am trying to understand how the map works in FP. I want to test how does the map work in Functional Programming.
Below is the testing code.
var R = require('ramda');
var M = require('ramda-fantasy').Maybe;
var Just = M.Just;
var Nothing =…

Sam Liaw
- 51
- 2
- 3
0
votes
1 answer
Apply list of functions to maybe value in Javascript
I'm using ramda-fantasy for the monads. I have a string inside a maybe and a some functions that will perform regex matches on a string and return a Maybe String.
How do I map the maybe to apply all of the functions and concatenate the result?
I…

Marcelo Lazaroni
- 9,819
- 3
- 35
- 41
-1
votes
1 answer
Ramda: Is there a way to find particular key value is nested object?
I want to find particular key value is nested object or not.
{
'a': {
'area': 'abc'
},
'b': {
'area': {
'city': 'aaaa',
'state': 'ggggg'
}
}
}
In above example, I want to find 'a' and 'b' is object or nested object?

Anusha Nilapu
- 39
- 2