Specification for interoperability of common algebraic structures in JavaScript
https://www.travis-ci.com/github/fantasyland/daggy/requests:
Could not authorize build request for fantasyland/daggy.
$ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Prelude> data List a = Nil | Cons a (List a) deriving Show
Prelude> show Nil
"Nil"
Prelude> show Cons
<interactive>:3:1: error:
• No instance for (Show (a0 -> List a0 -> List a0))
arising from a use of ‘show’
(maybe you haven't applied a function to enough arguments?)
• In the expression: show Cons
In an equation for ‘it’: it = show Cons
// show(List)
{"@@tags": ["Cons", "Nil"], "@@type": "List", "Cons": List.Cons, "Nil":
List.Nil, "is": function $isType(val) {
return typeName === type (val);
}, "prototype": {"@@show": function sum$toString() {
return this.constructor[TYPE] + '.' +
this[TAG] + arrToString (this[VALUES]);
}, "cata": function sum$cata(fs) {
var tags = this.constructor[TAGS];
var tag;
for (var idx = 0; idx < tags.length; idx += 1) {
tag = tags[idx];
if (!fs[tag]) {
throw new TypeError (
"Constructors given to cata didn't include: " + tag
);
}
}
return fs[this[TAG]].apply (fs, this[VALUES]);
}, "constructor": <Circular>, "foo": "foo", "toString": function sum$toString() {
return this.constructor[TYPE] + '.' +
this[TAG] + arrToString (this[VALUES]);
}}, "toString": function typeRepToString() {
return this[TYPE];
}}
List
not List.Nil
Applicative
I see v['fantasy-land/ap'](A['fantasy-land/of'](x => x))
... are these real object properties?
@agriffis: Yes, these are real properties. FantasyLand used to specify things like map
, ap
, and of
, but at the request of Ramda and others, these were replaced by impossible-to-mistake names that for many implementations are just aliases to their simply-named counterparts. The main issue is that it's difficult to know if MyGeospatialObject.map
has to do with Functors or cartography.
As to wrapping your head around it, I highly recommend this tutorial: http://www.tomharding.me/fantasy-land/
const foldThings = reduce(doSomeFolding)(seed)(foldable)
, you can align the arguments to reduce "vertically".. I wish I knew how to get it to show up as I mean here, but hoping someone knows what i mean
IO
typically means, but it takes an input you can transform before it consumes it with io.run()
Hello. I am wondering how chain
works with classes that have 2 types such as Either or Future.
If I have a Future instance with a certain "left" type. If I chain it, does the chaining function have to return a future with the same type as the "left" value?
Example:
const myFuture: Future<string, number> = getSomeFutureInstance()
function fetchSomething (x: number): Future<Error, Result> {
// ... implementation
}
// Is this call legal?
// If yes, how can I know if the result is Future<string, Result> or Future<Error, Result>
// Both the first call or the chained call could have failed.
const result = myFuture.chain(fetchSomething)