Skip to content
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

Ensure all instances delegate to existing datatypes combinators. #75

Closed
raulraja opened this issue Apr 20, 2017 · 1 comment
Closed
Assignees
Labels

Comments

@raulraja
Copy link
Member

raulraja commented Apr 20, 2017

It's common to stack overflow if instances of Monad for example don't provide overrides that delegate to the Datatype impl which is usually the shortest and more efficient path.

For example when creating an instance for Monad and your datatype contains map, ap and others, do not let the methods in the Monad hierarchy to stay autoimplemented and provide instead overrides that delegate to the datatype because the default implementations are usually non-effitient and can lead to stack overflow errors.

For example Monad implements ap in terms of flatMap, and Applicative implements map in terms of ap. While this may be ok for simple datatypes it's gonna blow up in cases such as EitherT and other more complex ones.

Each datatype should have separate classes for each instance it implements for example. Instead of having a single IdMonad we should have IdMonad: IdApplicative and IdApplicative: IdFunctor and so on where in each class there is a delegation of the corresponding methods to the ones present in the datatype.

@pakoito
Copy link
Member

pakoito commented Jul 22, 2017

Closed by #130

@pakoito pakoito closed this as completed Jul 22, 2017
ambrusadrianz pushed a commit to ambrusadrianz/arrow that referenced this issue Oct 22, 2019
rachelcarmena added a commit that referenced this issue Feb 24, 2021
rachelcarmena added a commit that referenced this issue Feb 24, 2021
* 0.11.0/bio (#1975)

* BIO - Part 1 (#1851)

* Add E param

* Fix imports & types

* Add RaiseError case

* Refactor IO name

* [BIO]: include `E` into IOFrame & IORunLoop (#1859)

* Rewrite IOFrame

* Update IORunLoop & fix resulting combinators

* Move public code to IO.kt

* Refactor Right to Success

* IO: IOConnection & IOBracket (#1870)

* Update ForwardCancelable

* Update IOBracket

* Remove KindConnection and refactor into IOConnection

* IO Concurrency combinators & Green Build (#1892)

* BIO - Part 1 (#1851)

* Add E param

* Fix imports & types

* Add RaiseError case

* Refactor IO name

* [BIO]: include `E` into IOFrame & IORunLoop (#1859)

* Rewrite IOFrame

* Update IORunLoop & fix resulting combinators

* Move public code to IO.kt

* Refactor Right to Success

* IO: IOConnection & IOBracket (#1870)

* Update ForwardCancelable

* Update IOBracket

* Remove KindConnection and refactor into IOConnection

* Rewrite UnsafePromise

* Rewrite ParMap2

* Update IOParMap3

* Update IORacePair

* Update IORaceTriple

* Fix tests

* Fix KIO benchmarks

* Fix imports Ank

* Fix IOExample

* Fix unused imports

* Fix imports benchmarks

* Fix arrow-integrations-retrofit-adapter

* Fix FpToTheMax & typeclasses example

* KtLintFormat

* Fix IOTest

* Fix more tests

* Fix merge conflicts

* KtLintFormat

* Fix MaybeK bracket and use it for QueueTest

* Throw proper exception in impossible cases

* Revert removing runAsync

* Fix build

* KtLintFormat

* Update version

* Conf: separate 0.11.0 version

* Fix doc generation and validation failures (#75)

* After releasing 0.10.5: just considering one wip version (#76)

Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
Co-authored-by: Simon Vergauwen <vergauwen.simon@gmail.com>
Co-authored-by: raulraja <raulraja@users.noreply.github.com>
rachelcarmena added a commit that referenced this issue Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants