Skip to content
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 Nov 15, 2020
0acc6fc
Implement left version of Apply
JordanMartinez Nov 26, 2020
610efd5
Implement left version of Applicative
JordanMartinez Nov 26, 2020
6baa15b
Update definitino of MonadLeft to depend on ApplicativeLeft
JordanMartinez Nov 26, 2020
8bada1b
Add left versions of whenM and unlessM
JordanMartinez Nov 26, 2020
104768c
Implement qualified do for MonadLeft
JordanMartinez Nov 26, 2020
5f4da8a
Change l prefix to Left suffix
JordanMartinez Dec 18, 2020
a193890
Abbreviate ldiscard implementation
JordanMartinez Dec 18, 2020
3a0ed53
Update implementation of compoesKleisliLeft to match right counterpart
JordanMartinez Dec 18, 2020
948d34e
Change w to m
JordanMartinez Dec 18, 2020
99b4266
Fix compiler error
JordanMartinez Dec 18, 2020
4793eec
Fix references to lwhen and lunless to their new names
JordanMartinez Dec 18, 2020
32a32a1
Remove unused import
JordanMartinez Dec 18, 2020
92dd8ca
Merge branch 'master' into addBindLeft
JordanMartinez Aug 23, 2021
f80b235
Move files into Control.Bifunctor module
JordanMartinez Aug 24, 2021
4484988
Update module names to match files
JordanMartinez Aug 24, 2021
1c5b583
Add pure export to Qualified module
JordanMartinez Aug 24, 2021
5f23d85
Update docs to use `BiLeft` convention
JordanMartinez Aug 24, 2021
5efcadf
Add kind sig to BindLeft
JordanMartinez Aug 24, 2021
3354b83
Add kind sig to other type classes
JordanMartinez Aug 24, 2021
f188683
Fix remaining import issues
JordanMartinez Aug 24, 2021
a3e9546
Change type paramter to m
JordanMartinez Aug 24, 2021
6bc197a
Move files out of Bifunctor folder
JordanMartinez Aug 25, 2021
a64efb1
Drop Bifunctor module prefix on MonadLeft classes
JordanMartinez Aug 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/Control/MonadLeft/Qualified.purs
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
Copy link
Copy Markdown
Contributor Author

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.do rather than MonadLeft.do?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MonadLeft.do seems more meaningful to me than Flip.do, but writing MonadLeft.ado for a type with only an ApplicativeLeft instance and no MonadLeft is odd.

Copy link
Copy Markdown
Contributor Author

@JordanMartinez JordanMartinez Dec 18, 2020

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.ado less of a "hey, this thing is a monad!" and more of a "hey, we're using the MonadLeft type class hierarchy here." That's how I read Ix.do, React.do, and Hooks.do.

-- | 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

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