Folktale is a suite of libraries for generic functional programming in JavaScript that allows you to write elegant modular applications with fewer bugs and more reuse.
Questions tagged [folktale]
20 questions
9
votes
0 answers
Handling forking on different levels of Tasks
I'm really stuck on handling different levels of Tasks in Ramda. I'm trying to build a script to parse LESS files for comments and build a pattern library site from the data in the comments and inline HTML from an example file. It's all working…

SpaceBeers
- 13,617
- 6
- 47
- 61
9
votes
3 answers
Mapping over an array of Tasks in Javascript
So I've started looking at Ramda / Folktale. I'm having an issue trying to map over an array of Tasks that comes from a directory. I'm trying to parse file contents.
var fs = require('fs');
var util = require('util');
var R = require('ramda');
var…

SpaceBeers
- 13,617
- 6
- 47
- 61
4
votes
1 answer
What is Folktale's Future for?
Background
I am reading every inch of the docs and trying to learn about Folktale as much as I can.
Recently, I decide to try Future.
Do we need a Future?
Now while I understand the difference between Task and Promise and between Task and Future (…

Flame_Phoenix
- 16,489
- 37
- 131
- 266
4
votes
1 answer
Does folktale have an IO monad?
I've been exploring the folktale library and found a wealth of useful constructs. After using Tasks via control.async and data.task, I wanted to use an IO monad, but can't seem to find it. Given how rich folktale is, I am surprised and wondering…

foxdonut
- 7,779
- 7
- 34
- 33
3
votes
1 answer
How to extract the value out of Monads in the Crocks javascript library
I understand that monads typically don't want to unwrap the underlying value because it may or may not exist. In my use case I would like to use functional programming techniques, using ramda for a functional library and Crocks for an algebraic data…

Justin Hoyt
- 148
- 1
- 9
3
votes
2 answers
Convert Fluture Future to folktale Result
I have the following sample code to fetch a uuid:
const Result = require('folktale/result')
const Future = require('fluture')
Future.prototype.flatMap = Future.prototype.chain
const fetch = Future.encaseP(require('node-fetch'))
const message = err…

vamsiampolu
- 6,328
- 19
- 82
- 183
3
votes
1 answer
By using functional programming javascript with folktale2, how to access results of previous tasks gracefully?
A task has a few steps, if each step's input is only from direct last step, it is easy. However, more often, some steps are depend on not only the direct last step.
I can work out via several ways, but all end up with ugly nested code, I hope anyone…

Ron
- 6,037
- 4
- 33
- 52
3
votes
1 answer
Can `Either` types be transformed to `Task` types?
If I have a Task that has an Either err b for the right (success) value, how can I combine / merge / transform them so the success value is available directly in the .fork(), not wrapped in an Either?
const Task = require('data.task'); //…

Robert K. Bell
- 9,350
- 2
- 35
- 50
2
votes
1 answer
Folktale / fantasyland Maybe not working as expected
Reading Frisbys guide to functional programming, currently on the chapter about Maybe. In the appendix the book suggests using either folktale or fantasyland.
However in both libraries Maybe doesn't seem to be work as described in the book.
const…

Bill Johnston
- 1,160
- 1
- 14
- 31
1
vote
0 answers
Pure Asynchronous Tasks in Javascript
Combining Ramda and Folktale functors
_fetchLists is a function that performs an async operation, it takes the following arguments:
fetchAlllists: an async function that resolves with Result functor of an array of list objects
listIds: an array of…

Nizar
- 21
- 1
- 1
- 3
1
vote
1 answer
migrating from data.task to folktale on handling rejection
In data.task package, I could resolve or reject a api call as following:
import Task from 'data.task';
import fs from 'fs';
const readFile = (filename, enc) => {
return new Task((rej, res) =>
fs.readFile(filename, enc, (err, contents) => {
…

leogoesger
- 3,476
- 5
- 33
- 71
0
votes
1 answer
fantasy-land confusion on ap method signature
In fantasy-land spec, the signature for ap method is defined as
fantasy-land/ap :: Apply f => f a ~> f (a -> b) -> f b
This translates as: The container f with value a has a method ap which takes a parameter container f with value of a function (a…

rsmoorthy
- 2,284
- 1
- 24
- 27
0
votes
0 answers
Folktale: combine Result and Task (or just promise)
It's a bite of broken code:
async function foo() {
return maybeMonad
.map((resultMonad) => resultMonad
.matchWith({
Error: (errorMonad) => errorMonad,
Ok: (okMonad) => okMonad
.map(async (context) => {
…

HAGer
- 21
- 5
0
votes
2 answers
How to apply properties of an object to functions?
I want to apply different functions to some object properties. Lets say I have this object:
const person = {
name: 'John',
age: 30,
friends: [],
};
and i have some functions that i want to apply to those properties:
const upperCase = str =>…

David Sttivend Angel
- 113
- 2
- 10
0
votes
2 answers
IO as First In Composition Chain
I am interested to experiment with Haskell-like IO monads in my JavaScript function compositions.
Something like Folktale has Task seems similar to Haskell's IO in that it's lazy, and thus technically pure. It represents an action that can occur in…

Aaron
- 3,249
- 4
- 35
- 51