More details to follow. I've created this ticket to be able to refer to from related preparatory commits.
In a nutshell the FTP (Foldable/Traversable-Proposal) sub-goal of the BBP (Burning-Bridges-Proposal) includes to be able to compile code like the following w/o errors (due to conflicting definitions):
Other goals include to generalise/weaken type-signatures where possible w/o breaking (much) compatibility with existing code. An in-depth design-document is in the works.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
The medium-sized patch in D209 implements the **first phase**, namely to re-export solely the two type-classes Foldable and Traversable (sans any methods) from Prelude
I think if you're doing this, it would make sense to generalize these too:
null::(Foldablef)=>fa->Boolnull=foldr(\__->False)Truelength::(Foldablef)=>fa->Intlength=foldl'(\k_->k+1)0--and even though it's a very strange thing alreadygenericLength::(Foldablef,Numn)=>fa->ngenericLength=foldr(\_k->1+k)0
rwbarton points out that there are optimized versions of these for various things, and that most containers use size instead of length. Therefore, I would propose instead adding size and null to the Foldable class, with default definitions as above.
rwbarton points out that there are optimized versions of these for various things, and that most containers use size instead of length. Therefore, I would propose instead adding size and null to the Foldable class, with default definitions as above.
Extending Foldable has become a ticket of its own at #9621 (closed)
Generalise (some of) Data.List to Foldables (re #9568)This replaces the entities in Data.List conflicting with Data.Foldablewith re-exports of the generalised version from Data.Foldable.As of this commit, the following compiles w/o error module XPrelude (module X) where import Control.Monad as X import Data.Foldable as X import Data.List as X import Prelude as XReviewed By: austin, dfeuer, ekmettDifferential Revision: https://phabricator.haskell.org/D229
Generalise Data.List/Control.Monad to Foldable/TraversableThis flips the switch and replaces the entities in`Data.List`/`Control.Monad` conflicting with`Data.{Foldable,Traversable}` with re-exports of the more generalversions.As of this commit, the code below (which is also added as a test-case)compiles w/o error. module XPrelude (module X) where import Control.Monad as X import Data.Foldable as X import Data.List as X import Data.Monoid as X import Data.Traversable as X import Prelude as XThis addresses #9568Reviewed By: ekmett, austinDifferential Revision: https://phabricator.haskell.org/D235
Replying to [#9586 (closed) Herbert Valerio Riedel <hvr@…>]:
In [changeset:"b8f58392/ghc"]:
repository="ghc" revision="b8f583928fa6cb5371a872fc73080d2002dd87d9" Export Monoid(..)/Foldable(..)/Traversable(..)` from Prelude
This finally exposes also the methods of these 3 classes in the Prelude
in order to allow to define basic class instances w/o needing imports.
This almost completes the primary goal of #9586 (closed)
NOTE: fold, foldl', foldr', and toList are not exposed yet,
as they require upstream fixes for at least containers and
bytestring, and are not required for defining basic instances.
Off-topic for this ticket but why not also generalize filterM, forever, ..., replicateM_? Are there hangups about the letter M in the names of some of these functions?
Off-topic for this ticket but why not also generalize filterM, forever, ..., replicateM_? Are there hangups about the letter M in the names of some of these functions?
filterM cannot be generalized to Traversable in any sensible way—it needs something stronger. forever and replicateM_ should be easy.
Off-topic for this ticket but why not also generalize filterM, forever, ..., replicateM_? Are there hangups about the letter M in the names of some of these functions?
filterM cannot be generalized to Traversable in any sensible way—it needs something stronger. forever and replicateM_ should be easy.
I mean generalize from Monad to Applicative, not from [] to Traversable.
Given the ongoing discussion in e.g. the Libraries mailing list should the status still be closed? Are all the proposed changes in 7.10RC2? If so when will the 7.10 doc be updated to reflect them?
We are currently constructing a poll and summaries of two possible plans of action that will go out in the next day or so. Based on the results of that poll, which will likely run until the 28th or so, to give folks a couple of weeks to respond, Simon Peyton Jones and Simon Marlow will come to a decision on how we are going to proceed for 7.10.