summaryrefslogtreecommitdiff
path: root/libraries/base/Data
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Address review feedback on chiralityViktor Dukhovni2021-04-011-11/+45
| | | | Also added nested foldr example for `concat`.
* Chiral foldable caveatsViktor Dukhovni2021-04-011-3/+37
|
* Data.List specialization to []Oleg Grenrus2021-04-013-1568/+1345
| | | | | | | - Remove GHC.OldList - Remove Data.OldList - compat-unqualified-imports is no-op - update haddock submodule
* Implement BoxedRep proposalwip/boxed-repBen Gamari2021-03-072-10/+58
| | | | | | | | | | | | | | | | | | | | | | | This implements the BoxedRep proposal, refactoring the `RuntimeRep` hierarchy from: ```haskell data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ... ``` to ```haskell data RuntimeRep = BoxedRep Levity | ... data Levity = Lifted | Unlifted ``` Updates binary, haddock submodules. Closes #17526. Metric Increase: T12545
* Add cmpNat, cmpSymbol, and cmpCharDaniel Winograd-Cort2021-03-031-0/+125
| | | | | | | Add Data.Type.Ord Add and update tests Metric Increase: MultiLayerModules
* Add the docspec:base rule to HadrianHécate2021-02-221-0/+3
|
* base: Fix order of infix declarations in Data.FunctorBen Gamari2021-02-181-2/+2
| | | | | | | As pointed in #19284, previously the order was a bit confusing. This didn't affect the meaning but nevertheless it's much clearer now. Closes #19284.
* Rectify the haddock markup surrounding symbols for foldl' and foldMap'Hécate Moonlight2021-02-181-23/+23
| | | | closes #19365
* Remove Data.Semigroup.OptionSimon Jakobi2021-02-131-88/+0
| | | | | | Bumps the binary and deepseq submodules. Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/15028.
* Fix typosBrian Wignall2021-02-061-1/+1
|
* base: Fix since-annotation for Data.List.singletonSimon Jakobi2021-02-061-1/+1
|
* The Char kind (#11342)Daniel Rogozin2021-02-061-2/+11
| | | | | | | | | | | | | | | | | | | | | | Co-authored-by: Rinat Stryungis <rinat.stryungis@serokell.io> Implement GHC Proposal #387 * Parse char literals 'x' at the type level * New built-in type families CmpChar, ConsSymbol, UnconsSymbol * New KnownChar class (cf. KnownSymbol and KnownNat) * New SomeChar type (cf. SomeSymbol and SomeNat) * CharTyLit support in template-haskell Updated submodules: binary, haddock. Metric Decrease: T5205 haddock.base Metric Increase: Naperian T13035
* Remove misleading 'lazy' pattern matches from 'head' and 'tail' in ↵wygulmage2021-02-051-2/+2
| | | | Data.List.NonEmpty
* Fix accidental unsoundness in Data.Typeable.Internal.mkTypeLitFromStringRyan Scott2021-02-011-1/+1
| | | | | | | | | An accidental use of `tcSymbol` instead of `tcNat` in the `TypeLitNat` case of `mkTypeLitFromString` meant that it was possible to unsafely equate `Nat` with `Symbol`. A consequence of this is that you could write `unsafeCoerce`, as observed in #19288. This is fixed easily enough, thankfully. Fixes #19288.
* Implement #18519Koz Ross2021-01-271-0/+38
|
* Fix doctest examples in Data.BitsOleg Grenrus2021-01-271-3/+7
|
* Add instances for GHC.Tuple.SoloBen Gamari2021-01-274-0/+32
| | | | | | | | | | | | | | | The `Applicative` instance is the most important one (for array/vector/sequence indexing purposes), but it deserves all the usual ones. T12545 does silly 1% wibbles both ways, it seems, maybe depending on architecture. Metric Increase: T12545 Metric Decrease: T12545
* FiniteBits for some newtype instances, notes on whyKoz Ross2021-01-231-7/+25
|
* Add headers for Data.Bits documentationKoz Ross2021-01-231-2/+3
|
* Add @since annotations for And, Ior, Xor, Iff type class instancesKoz Ross2021-01-231-9/+45
|
* Implement #15993Koz Ross2021-01-231-644/+76
|
* Enhance Data instance generationSylvain Henry2021-01-221-5/+12
| | | | | | | | | | | | | | | | Use `mkConstrTag` to explicitly pass the constructor tag instead of using `mkConstr` which queries the tag at runtime by querying the index of the constructor name (a string) in the list of constructor names. Perf improvement: T16577(normal) ghc/alloc 11325573876.0 9249786992.0 -18.3% GOOD Thanks to @sgraf812 for suggesting an additional list fusion fix during reviews. Metric Decrease: T16577
* Add examples for Complex, (,,) and (,,,) Eq2 etc instancesOleg Grenrus2021-01-181-0/+51
|
* Add lifted instances for 3 and 4 tuplesOleg Grenrus2021-01-181-0/+113
|
* Add Eq1, Show1, Read1 Complex instancesOleg Grenrus2021-01-181-0/+20
|
* Third pass on doctest corrections.Oleg Grenrus2021-01-172-8/+24
| | | | With `-K500K` rts option stack overflows are more deterministic
* Remove references to ApplicativeDo in the base haddocksHécate2021-01-133-32/+2
|
* Correct more doctestsOleg Grenrus2021-01-105-10/+10
|
* More tidy synopses, and new generative recursionViktor Dukhovni2021-01-091-69/+260
| | | | | | | | - Further correction and reconcialation with new overview of the existing synopses. Restored some "Tree" examples. - New section on generative recursion via Church encoding of lists.
* Reconcile extant synopses with new overview proseViktor Dukhovni2021-01-091-186/+323
| | | | | | | | | | | - Renamed new "update function" to "operator" from synopses - More accurate divergence conditions. - Fewer references to the Tree structure in examples, which may not have the definition close-by in context in other modules, e.g. Prelude. - Improved description of foldlM and foldrM - More detail on Tree instance construction - Misc fixes
* More truthful synopsis examplesViktor Dukhovni2021-01-091-11/+14
|
* New overview of Foldable classViktor Dukhovni2021-01-092-53/+750
| | | | Also updated stale external URL in Traversable
* Correct doctestsOleg Grenrus2021-01-0213-6/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's simpler to assume that base is NoImplicitPrelude, otherwise running doctest on `GHC.*` modules would be tricky. OTOH, most `GHC.List` (where the most name clashes are) examples could be changed to use `import qualified Data.List as L`. (GHC.List examples won't show for Foldable methods...). With these changes majority of doctest examples are GHCi-"faithful", my WIP GHC-independent doctest runner reports nice summary: Examples: 582; Tried: 546; Skipped: 34; Success: 515; Errors: 33; Property Failures 2 Most error cases are *Hangs forever*. I have yet to figure out how to demonstrate that in GHCi. Some of divergences are actually stack overflows, i.e. caught by runtime. Few errorful cases are examples of infinite output, e.g. >>> cycle [42] [42,42,42,42,42,42,42,42,42,42... while correct, they confuse doctest. Another erroneous cases are where expected output has line comment, like >>> fmap show (Just 1) -- (a -> b) -> f a -> f b Just "1" -- (Int -> String) -> Maybe Int -> Maybe String I think I just have to teach doctest to strip comments from expected output. This is a first patch in a series. There is plenty of stuff already.
* Add Monoid instances for Product and ComposeJoe Hermaszewski2020-12-222-0/+11
| | | | Semigroup too of course
* Revert "Implement BoxedRep proposal"Ben Gamari2020-12-152-74/+26
| | | | | | This was inadvertently merged. This reverts commit 6c2eb2232b39ff4720fda0a4a009fb6afbc9dcea.
* Implement BoxedRep proposalAndrew Martin2020-12-142-26/+74
| | | | | | | | | | | | | | | | | | This implements the BoxedRep proposal, refacoring the `RuntimeRep` hierarchy from: ```haskell data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ... ``` to ```haskell data RuntimeRep = BoxedRep Levity | ... data Levity = Lifted | Unlifted ``` Closes #17526.
* Apply suggestion to libraries/base/Data/Foldable.hschessai2020-11-301-1/+1
|