Skip to content

Add Monad, export Monad, Functor and Either#488

Merged
tmcdonell merged 2 commits intoAccelerateHS:masterfrom
dpvanbalen:master
Jan 21, 2021
Merged

Add Monad, export Monad, Functor and Either#488
tmcdonell merged 2 commits intoAccelerateHS:masterfrom
dpvanbalen:master

Conversation

@dpvanbalen
Copy link
Copy Markdown
Contributor

Description
Adds a Monad typeclass, and exports two modules (Functor and Either) which I was surprised to see unexported.

Motivation and context
While toying with a little Accelerate project, playing around with the pattern synonyms, I found myself implementing (>>=) for Maybe, and was surprised to see it not in Accelerate.

How has this been tested?
The Show instance looked reasonable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist
Go over all the following points, and put an x in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@tomsmeding
Copy link
Copy Markdown
Member

tomsmeding commented Jan 21, 2021

Just passing by, looks interesting!

  • The @since 1.2.0.0 in Monad.hs should probably be 1.3.0.1, or whatever is to be the next version. Don't know that the protocol is here.
  • Is RebindableSyntax really necessary in Monad.hs? Looks like a perfectly normal file.
  • No Applicative?

@dpvanbalen
Copy link
Copy Markdown
Contributor Author

dpvanbalen commented Jan 21, 2021

Just passing by, looks interesting!

* The `@since 1.2.0.0` in Monad.hs should probably be 1.3.0.1, or whatever is to be the next version. Don't know that the protocol is here.

Oops, I copied that part from Functor. I guess 1.4.0.0 is the next version?

* Is `RebindableSyntax` really necessary in Monad.hs? Looks like a perfectly normal file.

Another oops, that is not needed.

* No `Applicative`?

Sadly no, we can't follow the MAP because there's no Elt (a -> b) instance. (Of course, that doesn't stop you from writing an Applicative class, you just can't use it. :) )

@tomsmeding
Copy link
Copy Markdown
Member

tomsmeding commented Jan 21, 2021

Of course, that doesn't stop you from writing an Applicative class, you just can't use it. :)

There are limits to the amount of useless work we can get away with as academics. Makes sense :)

@dpvanbalen
Copy link
Copy Markdown
Contributor Author

Should the documentation reflect the lack of Applicatives? I suppose it's not obvious why it's missing, and it might cause confusion.
On another note, we could ofcourse keep adding these 'extended prelude'-type functions, datatypes, and classes, but maybe a whole 'MTL port' or 'Data.Bifunctor' should be in its own package or a separate module.

@tmcdonell tmcdonell merged commit 4e016b6 into AccelerateHS:master Jan 21, 2021
@tmcdonell
Copy link
Copy Markdown
Member

brilliant, thanks! (:

tmcdonell added a commit to tmcdonell/accelerate that referenced this pull request Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants