summaryrefslogtreecommitdiff
path: root/libraries/base/Data
Commit message (Collapse)AuthorAgeFilesLines
* Fix a few Note inconsistenciesBen Gamari2022-02-012-1/+1
|
* Fixes typo in documentation of the Semigroup instance of EquivalenceMichaWiedenmann12021-12-141-1/+1
|
* Data.Functor.Classes: fix Ord1 instance for DownVaibhav Sagar2021-12-141-1/+4
|
* Use HasCallStack and error in GHC.List and .NonEmptyOleg Grenrus2021-12-121-4/+5
| | | | | | | | | | | | | | | | | In addition to providing stack traces, the scary HasCallStack will hopefully make people think whether they want to use these functions, i.e. act as a documentation hint that something weird might happen. A single metric increased, which doesn't visibly use any method with `HasCallStack`. ------------------------- Metric Decrease: T9630 Metric Decrease: T19695 T9630 -------------------------
* Improve mtimesDefaultDavid Feuer2021-12-091-3/+22
| | | | | | | * Make 'mtimesDefault' use 'stimes' for the underlying monoid rather than the default 'stimes'. * Explain in the documentation why one might use `mtimesDefault`.
* Drop O(n^2) warning on concatViktor Dukhovni2021-12-091-3/+0
|
* A few more typosViktor Dukhovni2021-12-091-6/+7
|
* Fix typo and outdated link in Data.FoldableViktor Dukhovni2021-12-092-3/+4
| | | | | | | | Amazing nobody had reported the "Foldabla" typo. :-( The Traversable docs got overhauled, leaving a stale link in Foldable to a section that got replaced. Gave the new section an anchor and updated the link.
* Use italic big-O notation in Data.FoldableViktor Dukhovni2021-12-071-18/+18
|
* More specific documentation of foldr' caveatsViktor Dukhovni2021-12-071-3/+17
|
* List-monomorphic `foldr'`Viktor Dukhovni2021-12-071-1/+2
| | | | | | | | | | | | | While a *strict* (i.e. constant space) right-fold on lists is not possible, the default `foldr'` is optimised for structures like `Seq`, that support efficient access to the right-most elements. The original default implementation seems to have a better constant factor for lists, so we add a monomorphic implementation in GHC.List. Should this be re-exported from `Data.List`? That would be a user-visible change if both `Data.Foldable` and `Data.List` are imported unqualified...
* Revert "Data.List specialization to []"Matthew Pickering2021-12-033-1394/+1592
| | | | | | | | | | This reverts commit bddecda1a4c96da21e3f5211743ce5e4c78793a2. This implements the first step in the plan formulated in #20025 to improve the communication and migration strategy for the proposed changes to Data.List. Requires changing the haddock submodule to update the test output.
* Rename Data.Array.ByteArray -> Data.Array.ByteBodigrim2021-11-261-6/+6
|
* Rename Data.ByteArray to Data.Array.ByteArray + add TrustworthyBodigrim2021-11-261-6/+7
|
* Make INLINE/NOINLINE pragmas a bgi less constrainingSimon Peyton Jones2021-11-221-1/+4
| | | | | | | | We can inline a bit earlier than the previous pragmas said. I think they dated from an era in which the InitialPhase did no inlining. I don't think this patch will have much effect, but it's a bit cleaner.
* Provide in-line kind signatures for Data.Type.Ord.Compare.Andrew Pritchard2021-11-171-1/+1
| | | | | | Haddock doesn't know how to render SAKS, so the only current way to make the documentation show the kind is to write what it should say into the type family declaration.
* Fix Haddock markup on Data.Type.Ord.OrdCond.Andrew Pritchard2021-11-171-3/+4
|
* Improve ZipList section of Traversable overviewViktor Dukhovni2021-11-101-6/+15
| | | | | | | | - Fix cut/paste error by adding missing `c` pattern in `Vec3` traversable instance. - Add a bit of contextual prose above the Vec2/Vec3 instance sample code.
* Tweak descriptions of lines and unlinesViktor Dukhovni2021-10-251-19/+17
| | | | | It seems more clear to think of lines as LF-terminated rather than LF-separated.
* Fix infelicities in docs for lines, unlines, words, unwordsKoz Ross2021-10-191-13/+45
|
* Insert warnings in the documentation of dangerous functionsTom Sydney Kerckhove2021-10-152-0/+12
|
* Explain Endo, Dual, ... in lawsViktor Dukhovni2021-10-051-2/+40
|
* Adopt David Feuer's explantion of foldl' via foldrViktor Dukhovni2021-10-051-22/+31
|
* Minor wording tweaks/fixesViktor Dukhovni2021-10-052-24/+22
|
* Note elem ticket 20421Viktor Dukhovni2021-10-051-0/+4
|
* Note linear `elem` costViktor Dukhovni2021-10-051-10/+55
| | | | | This is a writeup of the state of play for better than linear `elem` via a helper type class.
* Add laws link and tweak Traversable class textViktor Dukhovni2021-10-051-4/+8
|
* Address some Foldable documentation nitsViktor Dukhovni2021-10-051-14/+18
| | | | | | - Add link to laws from the class head - Simplify wording of left/right associativity intro paragraph - Avoid needless mention of "endomorphisms"
* Improve error messages involving operators from Data.Type.OrdChristiaan Baaij2021-09-171-7/+10
| | | | Fixes #20009
* Remove dubious Eq1 and Ord1 Fixed instances. Fixes #20309Oleg Grenrus2021-09-111-9/+0
|
* Fix broken haddock @since fields in baseJoshua Price2021-09-082-0/+14
|
* base Data.Fixed: fix documentation typo: succ (0.000 :: Milli) /= 1.001 Jens Petersen2021-09-081-1/+1
| | | ie `succ (0000) == 0001` -- (not 1001)
* Export Solo from Data.TupleDavid Feuer2021-08-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | * The `Solo` type is intended to be the canonical lifted unary tuple. Up until now, it has only been available from `GHC.Tuple` in `ghc-prim`. Export it from `Data.Tuple` in `base`. I proposed this on the libraries list in December, 2020. https://mail.haskell.org/pipermail/libraries/2020-December/031061.html Responses from chessai https://mail.haskell.org/pipermail/libraries/2020-December/031062.html and George Wilson https://mail.haskell.org/pipermail/libraries/2021-January/031077.html were positive. There were no other responses. * Add Haddock documentation for Solo. * Give `Solo` a single field, `getSolo`, a custom `Show` instance that does *not* use record syntax, and a `Read` instance that accepts either record syntax or non-record syntax.
* Detect TypeError when checking for insolubilitysheaf2021-08-151-27/+17
| | | | | | | | | | | | | | | We detect insoluble Givens by making getInertInsols take into account TypeError constraints, on top of insoluble equalities such as Int ~ Bool (which it already took into account). This allows pattern matches with insoluble contexts to be reported as redundant (tyOracle calls tcCheckGivens which calls getInertInsols). As a bonus, we get to remove a workaround in Data.Typeable.Internal: we can directly use a NotApplication type family, as opposed to needing to cook up an insoluble equality constraint. Fixes #11503 #14141 #16377 #20180
* Consistent use of coercion and TypeApplicationsViktor Dukhovni2021-08-081-6/+11
| | | | | | | | | | | This makes the implementations of: - mapAccumL - mapAccumR - fmapDefault - foldMapDefault more uniform and match the approach in the overview.
* Rewrite of Traversable overviewViktor Dukhovni2021-08-081-211/+845
|
* Add Data.ByteArray, derived from primitiveBodigrim2021-08-051-0/+242
|
* Add Generically (generic Semigroup, Monoid instances) and Generically1 ↵Baldur Blöndal2021-08-021-1/+14
| | | | (generic Functor, Applicative, Alternative, Eq1, Ord1 instances) to GHC.Generics.
* base: Document overflow behaviour of genericLengthSimon Jakobi2021-08-021-0/+9
|
* Fix cut/paste typo foldrM should be foldlMViktor Dukhovni2021-07-021-1/+1
|
* Typos, minor comment fixesKrzysztof Gogolewski2021-06-221-8/+0
| | | | | | | | | | | | | | | | | | | - Remove fstName, sndName, fstIdKey, sndIdKey - no longer used, removed from basicKnownKeyNames - Remove breakpointId, breakpointCondId, opaqueTyCon, unknownTyCon - they were used in the old implementation of the GHCi debugger - Fix typos in comments - Remove outdated comment in Lint.hs - Use 'LitRubbish' instead of 'RubbishLit' for consistency - Remove comment about subkinding - superseded by Note [Kind Constraint and kind Type] - Mention ticket ID in a linear types error message - Fix formatting in using-warnings.rst and linear-types.rst - Remove comment about 'Any' in Dynamic.hs - Dynamic now uses Typeable + existential instead of Any - Remove codeGen/should_compile/T13233.hs This was added by accident, it is not used and T13233 is already in should_fail
* Improve wording of fold[lr]M documentation.Viktor Dukhovni2021-06-021-53/+77
| | | | | | | | | | | | | | | The sequencing of monadic effects in foldlM and foldrM was described as respectively right-associative and left-associative, but this could be confusing, as in essence we're just composing Kleisli arrows, whose composition is simply associative. What matters therefore is the order of sequencing of effects, which can be described more clearly without dragging in associativity as such. This avoids describing these folds as being both left-to-right and right-to-left depending on whether we're tracking effects or operator application. The new text should be easier to understand.
* Add pattern TypeRep (#19691), exported by Type.Reflection.Baldur Blöndal2021-05-191-5/+51
|
* Implement bitwise infix opsKoz Ross2021-05-191-0/+42
|
* Redesign withDict (formerly magicDict)Ryan Scott2021-04-291-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gives a more precise type signature to `magicDict` as proposed in #16646. In addition, this replaces the constant-folding rule for `magicDict` in `GHC.Core.Opt.ConstantFold` with a special case in the desugarer in `GHC.HsToCore.Expr.dsHsWrapped`. I have also renamed `magicDict` to `withDict` in light of the discussion in https://mail.haskell.org/pipermail/ghc-devs/2021-April/019833.html. All of this has the following benefits: * `withDict` is now more type safe than before. Moreover, if a user applies `withDict` at an incorrect type, the special-casing in `dsHsWrapped` will now throw an error message indicating what the user did incorrectly. * `withDict` can now work with classes that have multiple type arguments, such as `Typeable @k a`. This means that `Data.Typeable.Internal.withTypeable` can now be implemented in terms of `withDict`. * Since the special-casing for `withDict` no longer needs to match on the structure of the expression passed as an argument to `withDict`, it no longer cares about the presence or absence of `Tick`s. In effect, this obsoletes the fix for #19667. The new `T16646` test case demonstrates the new version of `withDict` in action, both in terms of `base` functions defined in terms of `withDict` as well as in terms of functions from the `reflection` and `singletons` libraries. The `T16646Fail` test case demonstrates the error message that GHC throws when `withDict` is applied incorrectly. This fixes #16646. By adding more tests for `withDict`, this also fixes #19673 as a side effect.
* Add Eq1 and Ord1 Fixed instancesOleg Grenrus2021-04-261-0/+9
|
* Use correct precedence in Complex's Read1/Show1 instancesRyan Scott2021-04-181-3/+7
| | | | Fixes #19719.
* Data.List strictness optimisations for maximumBy and minimumByHécate Moonlight2021-04-141-14/+21
| | | | follow-up from !4675
* Implement list `fold` and `foldMap` via mconcatKoz Ross2021-04-105-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - This allows specialized mconcat implementations an opportunity to combine elements efficiently in a single pass. - Inline the default implementation of `mconcat`, this may result in list fusion. - In Monoids with strict `mappend`, implement `mconcat` as a strict left fold: * And (FiniteBits) * Ior (FiniteBits) * Xor (FiniteBits) * Iff (FiniteBits) * Max (Ord) * Min (Ord) * Sum (Num) * Product (Num) * (a -> m) (Monoid m) - Delegate mconcat for WrappedMonoid to the underlying monoid. Resolves: #17123 Per the discussion in !4890, we expect some stat changes: * T17123(normal) run/alloc 403143160.0 4954736.0 -98.8% GOOD This is the expected improvement in `fold` for a long list of `Text` elements. * T13056(optasm) ghc/alloc 381013328.0 447700520.0 +17.5% BAD Here there's an extra simplifier run as a result of the new methods of the Foldable instance for List. It looks benign. The test is a micro benchmark that compiles just the derived foldable instances for a pair of structures, a cost of this magnitude is not expected to extend to more realistic programs. * T9198(normal) ghc/alloc 504661992.0 541334168.0 +7.3% BAD This test regressed from 8.10 and 9.0 back to exponential blowup. This metric also fluctuates, for reasons not yet clear. The issue here is the exponetial blowup, not this MR. Metric Decrease: T17123 Metric Increase: T9198 T13056
* Change foldl' to inline when partially applied (#19534)James Foster2021-04-071-14/+23
| | | | | And though partially applied foldl' is now again inlined, #4301 has not resurfaced, and appears to be resolved.