1. 18 Jan, 2016 1 commit
    • Eric Seidel's avatar
      un-wire-in error, undefined, CallStack, and IP · a7b751db
      Eric Seidel authored and Ben Gamari's avatar Ben Gamari committed
      I missed a crucial step in the wiring-in process of `CallStack` in D861,
      the bit where you actually wire-in the Name... This led to a nasty bug
      where GHC thought `CallStack` was not wired-in and tried to fingerprint
      it, which failed because the defining module was not loaded.
      
      But we don't need `CallStack` to be wired-in anymore since `error` and
      `undefined` no longer need to be wired-in. So we just remove them all.
      
      Updates haddock submodule.
      
      Test Plan: `./validate` and `make slowtest TEST=tc198`
      
      Reviewers: simonpj, goldfire, austin, hvr, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: goldfire, thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1739
      
      GHC Trac Issues: #11331
      a7b751db
  2. 23 Dec, 2015 1 commit
    • Eric Seidel's avatar
      Allow CallStacks to be frozen · 380b25ea
      Eric Seidel authored and Ben Gamari's avatar Ben Gamari committed
      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
      380b25ea
  3. 02 Oct, 2015 1 commit
    • Ben Gamari's avatar
      Move CallStack back to base · 74424346
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      CallStack requires tuples, instances of which are defined in GHC.Tuple.
      Unfortunately the change made in D757 to the `Typeable` deriving
      mechanism means that `GHC.Tuple` must import `GHC.Types` for types
      necessary to generate type representations.  This results in a cycle.
      
      Test Plan: Validate
      
      Reviewers: gridaphobe, austin, hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1298
      74424346
  4. 02 Sep, 2015 1 commit
    • Eric Seidel's avatar
      Use IP based CallStack in error and undefined · 6740d70d
      Eric Seidel authored and Ben Gamari's avatar Ben Gamari committed
      This patch modifies `error`, `undefined`, and `assertError` to use
      implicit call-stacks to provide better error messages to users.
      
      There are a few knock-on effects:
      
      - `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
        types for `error` and `undefined`.
      
      - `TysPrim.tyVarList` has been replaced with a new function
        `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
        subtle bugs when you need tyvars of different kinds. The naive
      
        ```
        tv1 = head $ tyVarList kind1
        tv2 = head $ tyVarList kind2
        ```
      
        would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
        would be applied incorrectly, treating `tv1` and `tv2` as the same
        tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
        and producing a single tyvar of each kind.
      
      - The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in
        ghc-prim.
      
      - The type `GHC.Exception.ErrorCall` has a new constructor
        `ErrorCallWithLocation` that takes two `String`s instead of one, the
        2nd one being arbitrary metadata about the error (but usually the
        call-stack). A bi-directional pattern synonym `ErrorCall` continues to
        provide the old API.
      
      Updates Cabal, array, and haddock submodules.
      
      Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
      liyang, bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D861
      
      GHC Trac Issues: #5273
      6740d70d
  5. 07 Nov, 2014 1 commit
  6. 22 Sep, 2013 1 commit
  7. 17 Sep, 2013 1 commit
  8. 07 Jun, 2013 1 commit
  9. 06 Jun, 2013 2 commits
    • Simon Peyton Jones's avatar
      Make GHC.Err depend on GHC.Integer · b3afa0a1
      Simon Peyton Jones authored
      GHC relies internally on GCh.Integer.Type.mkInteger from integer-gmp,
      but the dependency isn't visible to the build system, so we need to
      add it here.
      b3afa0a1
    • Simon Peyton Jones's avatar
      Re-jig SOURCE imports · 8d87b5bf
      Simon Peyton Jones authored
      * Do not have have an hs-boot file for Data.Typeable
      * Instead make all the loops go through
           GHC.Err (just a couple of magic functions)
           GHC.Exception (some non-exceptional functions)
      
      The main idea is
        a) don't involve classes in the hs-boot world
        b) loop through error cases where performance doesn't matter
        c) be careful not to SOURCE import things that are bottom,
           unless MkCore knows about them in eRROR_IDS, so that we
           see their strictness
      8d87b5bf
  10. 27 Oct, 2012 1 commit
    • ian@well-typed.com's avatar
      Remove commented types in module export lists · fda30027
      ian@well-typed.com authored
      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
      fda30027
  11. 04 Jul, 2012 1 commit
  12. 28 Feb, 2012 1 commit
  13. 18 Jun, 2011 1 commit
  14. 28 Jan, 2011 1 commit
  15. 05 Aug, 2008 3 commits
  16. 01 Aug, 2008 1 commit
  17. 30 Jul, 2008 1 commit
  18. 21 Jun, 2008 1 commit
  19. 16 Jun, 2008 1 commit
  20. 05 Mar, 2008 1 commit
  21. 20 Jan, 2008 1 commit
  22. 15 Jan, 2007 1 commit
  23. 03 Feb, 2005 1 commit
  24. 11 Jan, 2005 1 commit
  25. 26 Jul, 2004 1 commit
  26. 18 Sep, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-09-18 11:32:43 by simonmar] · a938d527
      simonmar authored
      Sort out the divide-by-zero situation.
      
      Some integer division operations called error on a divide by zero, and
      some didn't test for it.  Now we always raise the DivideByZero
      exception.
      
      MERGE TO STABLE
      a938d527
  27. 18 Jun, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-06-18 13:58:22 by simonpj] · 301802f9
      simonpj authored
      ---------------------------------------
      	    Rehash the handling of SeqOp
      	---------------------------------------
      
      See the comments in the commentary (Cunning Prelude Code).
      
      * Expunge SeqOp altogether
      
      * Add GHC.Base.lazy :: a -> a
        to GHC.Base
      
      * Add GHC.Base.lazy
        to basicTypes/MkId.  The idea is that this defn will over-ride
        the info from GHC.Base.hi, thereby hiding strictness and
        unfolding
      
      * Make stranal/WorkWrap do a "manual inlining" for GHC.Base.lazy
        This happens nicely after the strictness analyser has run.
      
      * Expunge the SeqOp/ParOp magic in CorePrep
      
      * Expunge the RULE for seq in PrelRules
      
      * Change the defns of pseq/par in GHC.Conc to:
      
      	{-# INLINE pseq  #-}
             	pseq :: a -> b -> b
             	pseq  x y = x `seq` lazy y
      
             	{-# INLINE par  #-}
             	par :: a -> b -> b
             	par  x y = case (par# x) of { _ -> lazy y }
      301802f9
  28. 09 May, 2002 1 commit
  29. 26 Apr, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-04-26 12:48:16 by simonmar] · f478c5a4
      simonmar authored
      - Add proper module headers to these guys
      - Remove \$Id\$
      - Update copyrights
      - Int.lhs and Word.lhs were just wrapped in \begin{code}..\end{code},
        so make them .hs files instead.
      f478c5a4
  30. 11 Apr, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-04-11 12:03:43 by simonpj] · 76a82fdf
      simonpj authored
      -------------------
      	Mainly derived Read
      	-------------------
      
      This commit is a tangle of several things that somehow got wound up
      together, I'm afraid.
      
      
      The main course
      ~~~~~~~~~~~~~~~
      Replace the derived-Read machinery with Koen's cunning new parser
      combinator library.   The result should be
      	* much smaller code sizes from derived Read
      	* faster execution of derived Read
      
      WARNING: I have not thoroughly tested this stuff; I'd be glad if you did!
      	 All the hard work is done, but there may be a few nits.
      
      The Read class gets two new methods, not exposed
      in the H98 inteface of course:
        class Read a where
          readsPrec    :: Int -> ReadS a
          readList     :: ReadS [a]
          readPrec     :: ReadPrec a		-- NEW
          readListPrec :: ReadPrec [a]	-- NEW
      
      There are the following new libraries:
      
        Text.ParserCombinators.ReadP		Koens combinator parser
        Text.ParserCombinators.ReadPrec	Ditto, but with precedences
      
        Text.Read.Lex				An emasculated lexical analyser
      					that provides the functionality
      					of H98 'lex'
      
      TcGenDeriv is changed to generate code that uses the new libraries.
      The built-in instances of Read (List, Maybe, tuples, etc) use the new
      libraries.
      
      
      Other stuff
      ~~~~~~~~~~~
      1. Some fixes the the plumbing of external-core generation. Sigbjorn
      did most of the work earlier, but this commit completes the renaming and
      typechecking plumbing.
      
      2. Runtime error-generation functions, such as GHC.Err.recSelErr,
      GHC.Err.recUpdErr, etc, now take an Addr#, pointing to a UTF8-encoded
      C string, instead of a Haskell string.  This makes the *calls* to these
      functions easier to generate, and smaller too, which is a good thing.
      
      In particular, it means that MkId.mkRecordSelectorId doesn't need to
      be passed "unpackCStringId", which was GRUESOME; and that in turn means
      that tcTypeAndClassDecls doesn't need to be passed unf_env, which is
      a very worthwhile cleanup.   Win/win situation.
      
      3.  GHC now faithfully translates do-notation using ">>" for statements
      with no binding, just as the report says.  While I was there I tidied
      up HsDo to take a list of Ids instead of 3 (but now 4) separate Ids.
      Saves a bit of code here and there.  Also introduced Inst.newMethodFromName
      to package a common idiom.
      76a82fdf
  31. 31 Jul, 2001 2 commits
  32. 28 Jun, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-06-28 14:15:04 by simonmar] · 4fb94ae5
      simonmar authored
      First cut of the Haskell Core Libraries
      =======================================
      
      NOTE: it's not meant to be a working snapshot.  The code is just here
      to look at and so the NHC/Hugs guys can start playing around with it.
      
      There is no build system.  For GHC, the libraries tree is intended to
      be grafted onto an existing fptools/ tree, and the Makefile in
      libraries/core is a quick hack for that setup.  This won't work at the
      moment without the other changes needed in fptools/ghc, which I
      haven't committed because they'll cause breakage.  However, with the
      changes required these sources build a working Prelude and libraries.
      
      The layout mostly follows the one we agreed on, with one or two minor
      changes; in particular the Data/Array layout probably isn't final
      (there are several choices here).
      
      The document is in libraries/core/doc as promised.
      
      The cbits stuff is just a copy of ghc/lib/std/cbits and has
      GHC-specific stuff in it.  We should really separate the
      compiler-specific C support from any compiler-independent C support
      there might be.
      
      Don't pay too much attention to the portability or stability status
      indicated in the header of each source file at the moment - I haven't
      gone through to make sure they're all consistent and make sense.
      
      I'm using non-literate source outside of GHC/.  Hope that's ok with
      everyone.
      
      We need to discuss how the build system is going to work...
      4fb94ae5