-
Notifications
You must be signed in to change notification settings - Fork 8
Implement initial BindLeft and MonadLeft #17
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b9075b6
Implement initial BindLeft and MonadLeft
JordanMartinez 0acc6fc
Implement left version of Apply
JordanMartinez 610efd5
Implement left version of Applicative
JordanMartinez 6baa15b
Update definitino of MonadLeft to depend on ApplicativeLeft
JordanMartinez 8bada1b
Add left versions of whenM and unlessM
JordanMartinez 104768c
Implement qualified do for MonadLeft
JordanMartinez 5f4da8a
Change l prefix to Left suffix
JordanMartinez a193890
Abbreviate ldiscard implementation
JordanMartinez 3a0ed53
Update implementation of compoesKleisliLeft to match right counterpart
JordanMartinez 948d34e
Change w to m
JordanMartinez 99b4266
Fix compiler error
JordanMartinez 4793eec
Fix references to lwhen and lunless to their new names
JordanMartinez 32a32a1
Remove unused import
JordanMartinez 92dd8ca
Merge branch 'master' into addBindLeft
JordanMartinez f80b235
Move files into Control.Bifunctor module
JordanMartinez 4484988
Update module names to match files
JordanMartinez 1c5b583
Add pure export to Qualified module
JordanMartinez 5f23d85
Update docs to use `BiLeft` convention
JordanMartinez 5efcadf
Add kind sig to BindLeft
JordanMartinez 3354b83
Add kind sig to other type classes
JordanMartinez f188683
Fix remaining import issues
JordanMartinez a3e9546
Change type paramter to m
JordanMartinez 6bc197a
Move files out of Bifunctor folder
JordanMartinez a64efb1
Drop Bifunctor module prefix on MonadLeft classes
JordanMartinez 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 hidden or 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,40 @@ | ||
| -- | Enables one to use `ado notation` and `do notation` on the left parameter | ||
| -- | of a Bifunctor. | ||
| -- | | ||
| -- | `ado notation` example | ||
| -- | ``` | ||
| -- | import Control.MonadLeft.Qualified as MonadLeft | ||
| -- | | ||
| -- | foo :: Either Int String -> Either String String | ||
| -- | foo comp = MonadLeft.ado | ||
| -- | a <- comp | ||
| -- | b <- comp | ||
| -- | in show $ a + b | ||
| -- | ``` | ||
| -- | `do notation` example | ||
| -- | ``` | ||
| -- | import Control.MonadLeft.Qualified as MonadLeft | ||
| -- | | ||
| -- | foo :: Either Int String -> Either String String | ||
| -- | foo comp = MonadLeft.do | ||
| -- | a <- comp | ||
| -- | b <- comp | ||
| -- | lpure $ show $ a + b | ||
| -- | ``` | ||
| module Control.MonadLeft.Qualified where | ||
JordanMartinez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import Control.ApplyLeft (class ApplyLeft, lapply) | ||
| import Control.BindLeft (class BindLeft, lbind, class DiscardLeft, ldiscard) | ||
| import Data.Bifunctor (class Bifunctor, lmap) | ||
|
|
||
| discard :: forall m a b r. DiscardLeft a => BindLeft m => m a r -> (a -> m b r) -> m b r | ||
| discard = ldiscard | ||
|
|
||
| bind :: forall m a b r. BindLeft m => m a r -> (a -> m b r) -> m b r | ||
| bind = lbind | ||
|
|
||
| apply :: forall m a b c. ApplyLeft m => m (a -> b) c -> m a c -> m b c | ||
| apply = lapply | ||
|
|
||
| map :: forall m a b c. Bifunctor m => (a -> b) -> m a c -> m b c | ||
| map = lmap | ||
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 the convention be
Flip.dorather thanMonadLeft.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.
MonadLeft.doseems more meaningful to me thanFlip.do, but writingMonadLeft.adofor a type with only anApplicativeLeftinstance and noMonadLeftis odd.Uh oh!
There was an error while loading. Please reload this page.
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 read
MonadLeft.do/MonadLeft.adoless of a "hey, this thing is a monad!" and more of a "hey, we're using theMonadLefttype class hierarchy here." That's how I readIx.do,React.do, andHooks.do.