| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add @since annotations to instances in `base`.
Test Plan:
* ./validate # some commets shouldn't break the build
* review the annotations for absurdities.
Reviewers: ekmett, goldfire, RyanGlScott, austin, hvr, bgamari
Reviewed By: RyanGlScott, hvr, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2277
GHC Trac Issues: #11767
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This introduces "freezing," an operation which prevents further
locations from being appended to a CallStack. Library authors may want
to prevent CallStacks from exposing implementation details, as a matter
of hygiene. For example, in
```
head [] = error "head: empty list"
ghci> head []
*** Exception: head: empty list
CallStack (from implicit params):
error, called at ...
```
including the call-site of `error` in `head` is not strictly necessary
as the error message already specifies clearly where the error came
from.
So we add a function `freezeCallStack` that wraps an existing CallStack,
preventing further call-sites from being pushed onto it. In other words,
```
pushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack
```
Now we can define `head` to not produce a CallStack at all
```
head [] =
let ?callStack = freezeCallStack emptyCallStack
in error "head: empty list"
ghci> head []
*** Exception: head: empty list
CallStack (from implicit params):
error, called at ...
```
---
1. We add the `freezeCallStack` and `emptyCallStack` and update the
definition of `CallStack` to support this functionality.
2. We add `errorWithoutStackTrace`, a variant of `error` that does not
produce a stack trace, using this feature. I think this is a sensible
wrapper function to provide in case users want it.
3. We replace uses of `error` in base with `errorWithoutStackTrace`. The
rationale is that base does not export any functions that use CallStacks
(except for `error` and `undefined`) so there's no way for the stack
traces (from Implicit CallStacks) to include user-defined functions.
They'll only contain the call to `error` itself. As base already has a
good habit of providing useful error messages that name the triggering
function, the stack trace really just adds noise to the error. (I don't
have a strong opinion on whether we should include this third commit,
but the change was very mechanical so I thought I'd include it anyway in
case there's interest)
4. Updates tests in `array` and `stm` submodules
Test Plan: ./validate, new test is T11049
Reviewers: simonpj, nomeata, goldfire, austin, hvr, bgamari
Reviewed By: simonpj
Subscribers: thomie
Projects: #ghc
Differential Revision: https://phabricator.haskell.org/D1628
GHC Trac Issues: #11049
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This can happen because the underlying primitive operations in
`integer-gmp` don't support negative shift-amounts, and since
`integer-gmp` can't throw proper exceptions and just provides a
low-level API, it simply segfaults instead...
This patch simply removes the `shift{L,R}` method definitions (and
defines `unsafeShift{L,R}` instead) whose default-impls fallback on
using `shift` which properly handles negative shift arguments.
This addresses #10571
Test Plan: harbormaster can do it
Reviewers: hvr, austin, rwbarton
Subscribers: rwbarton, thomie, bgamari
Differential Revision: https://phabricator.haskell.org/D1018
GHC Trac Issues: #10571
|
|
|
|
| |
Fixes #10571.
|
|
|
|
|
|
| |
Starting with Haddock 2.16 there's a new built-in support for since-annotations
Note: This exposes a bug in the `@since` implementation (see e.g. `Data.Bits`)
|
|
|
|
|
|
| |
The primops are implemented in the `integer-gmp2` (#9281) backend and
are already used for the `Bits Natural` instance but aren't used yet for
the `Bits Integer` instace. This commit fixes that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new function `Data.Bits.toIntegralSized` provides a similar
functionality to `fromIntegral` but adds validation that the
argument fits in the result type's size.
The implementation of `toIntegralSized` has been derived from `intCastMaybe`
(which is part of Herbert Valerio Riedel's `int-cast` package,
see http://hackage.haskell.org/package/int-cast)
Addresses #9816
Reviewed By: ekmett, austin
Differential Revision: https://phabricator.haskell.org/D512
|
|
|
|
|
|
|
|
|
|
|
| |
This removes the redundant "Minimal complete definition"-block included
in the Haddock comment since Haddock renders the `MINIMAL`-pragma as
well (which has is moved to the start of `class` definition for better
readability of the source code)
Morever, the references to `testBitDefault`, `bitDefault`, and
`popCountDefault` have been moved to the respective methods' Haddock
strings for which they can be used.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The property
countLeadingZeros . negate = const 0
doesn't generally hold and it's not such a useful property to state, as
it simply follows from "sign-bit == most-significant-bit" for FiniteBits
types which use twos-complement representation for negative values, and
even then it breaks down for 0...
TLDR, remove thinko from documentation of `countLeadingZeros`
|
|
|
|
|
|
| |
...some files more or less recently touched by me
[ci skip]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This exposes the newly added CLZ/CTZ primops from
e0c1767d0ea8d12e0a4badf43682a08784e379c6 (re #9340)
via two new methods `countLeadingZeros` and `countTrailingZeros`
in the `Data.Bits.FiniteBits` class.
The original proposal can be found at
http://www.haskell.org/pipermail/libraries/2014-August/023567.html
Test Plan: successful validate
Reviewers: ekmett, tibbe
GHC Trac Issues: #9532
Differential Revision: https://phabricator.haskell.org/D158
|
|
|
|
|
|
|
| |
Apart from simply making sense (avoid the conditional in 'shift'),
this makes left and right shifts on Integer more likely to inline
(plain 'shift' is just too large); and this in turn is important
when fixing the Integer case of #8832
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For some reason GHC fails to constant fold `zeroBits :: Int` and
`zeroBits :: Integer`; `ghc -show-iface` shows
$fBitsInt_$czeroBits :: GHC.Types.Int
{- Strictness: m,
Unfolding: (GHC.Types.I# (GHC.Prim.andI# 1 (GHC.Prim.notI# 1))) -}
Otoh, constant-folding works as expected, reducing `zeroBits` to 0 constant
for the other integer-types (= {Word,Int}{8,16,32,64}` and `Word`). So this
quickfix is actually just treating the symptom rather than the cause.
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
| |
This adds a new method to `Bits` which completes the Bits API
with a direct way to introduce a value with all bits cleared.
See also original proposal at
http://permalink.gmane.org/gmane.comp.lang.haskell.libraries/21157
|
|
|
|
| |
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
| |
The new primops (see also #7689) allow to optimize
`instance Bits Int` by allowing to operate directly on Int#
instead of having to convert to Word# and back to Int# again.
Authored-by: Chris Dueck <crdueck@uwaterloo.ca>
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes the markup at the top of `Control.Arrow`, and improves the
markup inside DEPRECATED strings.
(Haddock supports markup inside DEPRECATED messages, which allows to
turn references to Haskell entities into hyperlinks by using the usual
Haddock markup.)
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
|
|
| |
This interprets `Bool` as an 1-bit "unsigned" bit-field and provides a
simple (not particularily optimized) implementation to that end.
See "Proposal: Add `instance Bits Bool`" by @ekmett, Nov 2013,
http://permalink.gmane.org/gmane.comp.lang.haskell.libraries/20663
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
|
| |
This commit retroactively adds `/Since: 4.5.[01].0/` annotations to symbols
newly added/exposed in `base-4.5.[01].0` (as shipped with GHC 7.4.[12]).
See also 6368362f which adds the respective annotation for symbols newly
added in `base-4.7.0.0` (that goes together with GHC 7.8.1).
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
|
| |
This commit retroactively adds `/Since: 4.6.0.0/` annotations to symbols
newly added/exposed in `base-4.6.0.0` (as shipped with GHC 7.6.1).
See also 6368362f which adds the respective annotation for symbols newly
added in `base-4.7.0.0` (that goes together with GHC 7.8.1).
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These annotations were added in such a way, that the line
{{{
/Since: 4.7.0.0/
}}}
represents the last paragraph of the Haddock comment.
Maybe Haddock will have support for this meta-syntax at some point, and
be able to inherited the since-version property to the children of an
annotated symbol and display the since-version property in the rendered
documentation only in cases when it's not visually obvious (for
instance, when re-exporting documentation strings).
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This makes use of the new `{-# MINIMAL #-}` facility (see #7633)
for the following typeclasses
- `Bits`
- `Foldable`
- `Fractional`
- `Num`
- `MonadZip`
- `Read`
- `Show`
- `Storable`
- `Traversable`
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
|
|
|
| |
Now that HUGS and NHC specific code has been removed, this commit "folds"
the now redundant `#if((n)def)`s containing `__GLASGOW_HASKELL__`. This
renders `base` officially GHC only.
This commit also removes redundant `{-# LANGUAGE CPP #-}`.
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
|
|
|
|
|
|
| |
For rationale. see
http://permalink.gmane.org/gmane.comp.lang.haskell.ghc.devel/2349
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These comments are rather less useful now that haddock can give docs
with the same informatino in the module synopsis.
Having to maintain them when making changes to the library is a pain,
and when people forget about doing so there is nothing that checks that
the comments are right, so mistakes tend to linger.
Of the comments that my script detected, 78 of 684 were already
incorrect in one way or another, e.g. missing context:
Text.Show.showsPrec
Comment type: Int -> a -> ShowS
Actual type: Show a => Int -> a -> ShowS
wrong context:
Numeric.readInt
Comment type: Integral a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
Actual type: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
not following a class change (e.g. Num losing its Eq superclass):
Text.Read.Lex.readOctP
Comment type: Num a => ReadP a
Actual type: (Eq a, Num a) => ReadP a
not following the Exceptions change:
GHC.Conc.childHandler
Comment type: Exception -> IO ()
Actual type: SomeException -> IO ()
or just always been wrong:
GHC.Stable.deRefStablePtr
Comment type: StablePtr a -> a
Actual type: StablePtr a -> IO a
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Added testBit, bit, and popCount to the required set. They no longer
have default implementations as the Num constraint was removed from the
Bits class.
|
|
|
|
|
| |
Also add an INLINABLE pragma so that the function can be specialized at
the call site.
|
|
|
|
| |
popCountDefault from Data.Bits.
|
|
|
|
|
| |
This allows shifting by a non-statically known amount without
introducing a branch (to check for "overflow").
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Documentation notes that the second arg of shift[LR] must be positive,
yet many definitions of instance Bits rely on the class default, which
performs an unnecessary sign check.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Add explicit {-# LANGUAGE xxx #-} pragmas to each module, that say
what extensions that module uses. This makes it clearer where
different extensions are used in the (large, variagated) base package.
Now base.cabal doesn't need any extensions field
Thanks to Bas van Dijk for doing all the work.
|
| |
|
| |
|
|
|
|
|
|
|
| |
* Add INLINE pragmas to default methods for class Bits
* Remove redundant instance methods elsewhere, now that
the default method will do the job
|
| |
|
| |
|