a specification for algebraic data structures in JavaScript.
Questions tagged [fantasyland]
25 questions
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
1 answer
How to use daggy for conditional rendering in React
Lets say I have four components and I want to conditionally render them depending on a type prop using daggy:
In this example type prop value can be the string a, b, c or d
here is a working codesandbox example
import daggy from 'daggy';
import {…

rfc1484
- 9,441
- 16
- 72
- 123
0
votes
0 answers
Typescript signatures and category theory
I'm wondering if TypeScript right now is expressive enough to model some typical category theory type signatures.
For example, I may have a functor type defined as (I'm using Fantasy Land version of Damas–Hindley–Milner type…

RedGlow
- 773
- 7
- 13
0
votes
1 answer
Understanding Fantasyland `ap`
I'm trying to come to an understand of ap, but having trouble.
In fantasyland, James Forbes says:
First we teach a function how to interact with our type, by storing that function in a container just like any other value. ( Functions are values too…

adamoverflow
- 3
- 1
- 3
0
votes
2 answers
Sanctuary Js and Defining a Contravariant Functor
I am trying this from scratch learning about Contravariants and deeper knowledge of Sanctuary. The code "works" but again I don't have the types exactly right.
Here is the Contravariant
const {contramap: contramapFl, extract } =…

akaphenom
- 6,728
- 10
- 59
- 109
0
votes
0 answers
Trouble implementing a functor in typescript
I have been reading through Tom Harding's blog series on the fantasy-land spec, and this afternoon I was playing around with implementing a functor in typescript.
class Just {
private x: T
constructor (x: T) {
this.x = x
}
map…

Ziggy
- 21,845
- 28
- 75
- 104
0
votes
1 answer
Use ramda `sequence` to traverse a dictionary
How can I use ramda's sequence to traverse a dictionary?
Given the following dictionary
cars = {color: ['yellow', 'red'], year: [2017], model: ['coup', 'sedan']}
I'd like to produce the traversed result
all_cars = [
{color: 'yellow', year:…

Cirdec
- 24,019
- 2
- 50
- 100
0
votes
1 answer
Is using sequence the right approach to give monadic arguments to a function of arity greater than 1?
See the following code snippet:
const
fun1 = () => Either.of(1),
fun2 = () => Either.of(2),
fun3 = () => Either.of(3),
fun4 = curry((x, y, z) => Either.of(x + y + z)),
fun5 = x => Either.of(x + 1),
fun6 = () => pipeK(
() =>…

Matías Fidemraizer
- 63,804
- 18
- 124
- 206
0
votes
2 answers
Is it possible to constrain generic classes for specific methods?
Let's say I create a container in TypeScript. It could be any container but I'll use the following simple example:
class Container {
val: T;
constructor(t: T) {
this.val = t;
}
}
Say I'd like to offer a function so that if I have two…

paldepind
- 4,680
- 3
- 31
- 36
0
votes
2 answers
chaining (or mapping) Task containing a single data array to an array of Tasks
Part of learning Fanatasy Land/Folk Tale has lead me to creating some code. I am essnetially scnaning my network (via someLib) and uploading the results to a mongo repository. The scan returns back an array of results, while the upsert into mongo…

akaphenom
- 6,728
- 10
- 59
- 109