-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial version #1
Conversation
…aced names in method definition
to make method order consistant reoreder them as in fantasy-land
|
||
// instance Applicative (Func a) where | ||
// of :: b -> Func a b | ||
Func.of = (a) => Func((_) => a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this a few days ago. I'll go ahead and define it in sanctuary-type-classes. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah!
isEmpty, | ||
|
||
// createas container for a value which currently has no type. | ||
of: Of.of, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
make Future weaker (cant express failure) so it's simpler for our demonstrational purposes
t.ok(of(a).equals(Identity.of(a))) | ||
t.eqFL(Identity(of(a)), of(a).traverse((a) => Identity(a), Identity.of)) | ||
t.eqFL(of(Identity(of(a))), of(a).extend((a) => Identity(a))) | ||
t.eqFL(of(Identity(of(empty))), empty.extend((a) => Identity(a))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is (a) => Identity(a)
better written Identity
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identity
besides a -> Identity a
is also TypeRep Identity
and I wanted to be more explicit that a function is passed as argument, even though Identity
would work as well.
Object.assign({}, options, { preset: 'angular' }), | ||
parserOpts, | ||
(err, res) => cb(err, res != null ? res.releaseAs : res) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this file do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's referenced from package.json for semantic release stuff
I figured this the best place to discuss this approach in general. I still don't understand it completely, and so far have one question that bothers me: will we have to consider special Also for example you have an Pair.prototype.equals = function(b) {
return equals(this._1, b._1) && equals(this._2, b._2)
} But don't we have to consider special values like we do in |
if we know that some function It's would be useful when function just has constraint on some interface: // foldMap :: (Foldable f, Monoid m) => (f a, a -> m) -> m
// 1 - this is the special empty value. we don't need a
// function or some dictionary to get empty value
const foldMap = (f, as) => as.reduce((acc, a) => acc.concat(f(a)), empty /*[1]*/ )
foldMap(a => Max(a*a), Cons(1, Cons(2, Cons(3, Nil))))) // Max(9)
// foldMap :: (ChainRec m, Applicative m) => Free i a ~> (i -> m a) -> m a
// 1 - we don't need `TypeRep m` in order to access `chainRec`
// 2 - we don't need `TypeRep m` in order to access `of`
// once it's used with `chain` or `ap` it will "get" type
Free.prototype.foldMap = function(f) {
return /*[1]*/chainRec((next, done, v) => v.cata({
Pure: (x) => map(/*[2]*/of(x), done),
Lift: (x, g) => map(f(x), compose(done, g)),
Ap: (x, y) => map(ap(x.foldMap(f), y.foldMap(f)), done),
Chain: (x, g) => map(x.foldMap(f), compose(next, g)),
}), this)
} But if we do About |
Yeah, this is exactly what I was thinking about. The value we got from |
If we have |
Right, but anyway seems like with this system we would have to use something like I mean, suppose I don't need a type that delegates monoid functionality to the wrapped values, but I still will have to do |
This is so rad. Just saying |
@DrBoolean thanks! I'm thinking on it issue @rpominov pointed out. Currently only solution I see is to only call FL methods on objects but if you want to have |
TODO:
examples
readme
example
structuresexample
structuresrethink:
foldIfIsOf
quasi
itselfCurrent coverage is 100%