-
Notifications
You must be signed in to change notification settings - Fork 377
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
Add Alt, Plus and Alternative specs #197
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
27fe5ca
add Alternative typeclasses in readme and graph
safareli 0903767
reorder 'ap' arguments in Alternative's annihilation laws
safareli 68e6b42
add laws and update index.js
safareli 69655f7
rename pempty to zero
safareli 98e3634
add Maybe type for testing Alternative laws and refactor tests
safareli 2863e8c
fix MonadOr and MonadPlus implementations
safareli 05f01ac
fix squashed graph image
safareli cb5977d
remove monad{Zero,Plus,Or} specs
safareli 7e661ed
use A instead of M in M.zero()
safareli 09798ee
update signature of zero
safareli 05fe7c4
use fixed size for dependencies image
safareli 5edc75c
prefix 'id.js' with 'internal/' in readme
safareli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const {tagged} = require('daggy'); | ||
|
||
const fl = require('..'); | ||
const {equality} = require('./func'); | ||
|
||
const Compose = module.exports = tagged('c'); | ||
Compose[fl.of] = Compose; | ||
Compose.prototype[fl.ap] = function(f) { | ||
return Compose(this.c[fl.ap](f.c[fl.map](u => y => y[fl.ap](u)))); | ||
}; | ||
Compose.prototype[fl.map] = function(f) { | ||
return Compose(this.c[fl.map](y => y[fl.map](f))); | ||
}; | ||
Compose.prototype[fl.equals] = function(x) { | ||
return equality(this.c, x.c); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
const fl = require('../'); | ||
const equality = (x, y) => typeof x[fl.equals] === 'function' ? x[fl.equals](y) : x === y; | ||
|
||
module.exports = { | ||
equality, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const patch = require('./patch'); | ||
const Maybe = require('./maybe'); | ||
const Id = require('./id'); | ||
const Sum = require('./string_sum'); | ||
const Compose = require('./compose'); | ||
const {equality} = require('./func'); | ||
|
||
module.exports = { | ||
Maybe, | ||
Id, | ||
Sum, | ||
Compose, | ||
equality, | ||
patch, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should it be
Plus x => () -> x a
? Also maybe usep
instead ofx
?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.
In that case we should also add
forall a
I think, but i'm not familiar with that. maybe @joneshf could help here?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 think
forall
is kinda implicit in our loosely specified type system. What I was trying to say is thatx
is not a type here, it's a type constructor, so it cannot be in that position in signature.x a
is a type on the other hand.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 would use
f a
.f
to be consistent with other types