1. 29 Apr, 2011 1 commit
  2. 28 Apr, 2011 1 commit
  3. 22 Dec, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Tidy up rebindable syntax for MDo · ba05282d
      simonpj@microsoft.com authored
      For a long time an 'mdo' expression has had a SyntaxTable
      attached to it.  However, we're busy deprecating SyntaxTables
      in favour of rebindable syntax attached to individual Stmts,
      and MDoExpr was totally inconsistent with DoExpr in this
      regard.
      
      This patch tidies it all up.  Now there's no SyntaxTable on
      MDoExpr, and 'modo' is generally handled much more like 'do'.
      
      There is resulting small change in behaviour: now MonadFix is
      required only if you actually *use* recursion in mdo. This
      seems consistent with the implicit dependency analysis that
      is done for mdo.
      
      Still to do:
        * Deal with #4148 (this patch is on the way)
        * Get rid of the last remaining SyntaxTable on HsCmdTop
      ba05282d
  4. 05 Nov, 2010 1 commit
  5. 22 Oct, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Add rebindable syntax for if-then-else · 4e0c994e
      simonpj@microsoft.com authored
      There are two main changes
      
       * New LANGUAGE option RebindableSyntax, which implies NoImplicitPrelude
      
       * if-the-else becomes rebindable, with function name "ifThenElse"
         (but case expressions are unaffected)
      
      Thanks to Sam Anklesaria for doing most of the work here
      4e0c994e
  6. 14 Sep, 2010 1 commit
  7. 13 Sep, 2010 1 commit
  8. 22 Aug, 2010 1 commit
  9. 15 Jun, 2010 1 commit
  10. 09 Apr, 2010 1 commit
  11. 04 Mar, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Refactor part of the renamer to fix Trac #3901 · f1cc3eb9
      simonpj@microsoft.com authored
      This one was bigger than I anticipated!  The problem was that were
      were gathering the binders from a pattern before renaming -- but with
      record wild-cards we don't know what variables are bound by C {..}
      until after the renamer has filled in the "..".
      
      So this patch does the following
      
      * Change all the collect-X-Binders functions in HsUtils so that
        they expect to only be called *after* renaming.  That means they
        don't need to return [Located id] but just [id].  Which turned out
        to be a very worthwhile simplification all by itself.
      
      * Refactor the renamer, and in ptic RnExpr.rnStmt, so that it
        doesn't need to use collectLStmtsBinders on pre-renamed Stmts.
      
      * This in turn required me to understand how GroupStmt and
        TransformStmts were renamed.  Quite fiddly. I rewrote most of it;
        result is much shorter.
      
      * In doing so I flattened HsExpr.GroupByClause into its parent
        GroupStmt, with trivial knock-on effects in other files.
      
      Blargh.
      f1cc3eb9
  12. 30 Oct, 2009 1 commit
  13. 28 Oct, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Add 'rec' to stmts in a 'do', and deprecate 'mdo' · f04dead9
      simonpj@microsoft.com authored
      The change is this (see Trac #2798).  Instead of writing
      
        mdo { a <- getChar
            ; b <- f c
            ; c <- g b
            ; putChar c
            ; return b }
      
      you would write
      
        do { a <- getChar
           ; rec { b <- f c
                 ; c <- g b }
           ; putChar c
           ; return b }
      
      That is, 
        * 'mdo' is eliminated 
        * 'rec' is added, which groups a bunch of statements
          into a single recursive statement
      
      This 'rec' thing is already present for the arrow notation, so it  
      makes the two more uniform.  Moreover, 'rec' lets you say more
      precisely where the recursion is (if you want to), whereas 'mdo' just
      says "there's recursion here somewhere".  Lastly, all this works with
      rebindable syntax (which mdo does not).
      
      Currently 'mdo' is enabled by -XRecursiveDo.  So we now deprecate this
      flag, with another flag -XDoRec to enable the 'rec' keyword.
      
      Implementation notes:
        * Some changes in Lexer.x
        * All uses of RecStmt now use record syntax
      
      I'm still not really happy with the "rec_ids" and "later_ids" in the
      RecStmt constructor, but I don't dare change it without consulting Ross
      about the consequences for arrow syntax.
      f04dead9
  14. 23 Jul, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Add tuple sections as a new feature · 58521c72
      simonpj@microsoft.com authored
      This patch adds tuple sections, so that
      
      	(x,,z)  means   \y -> (x,y,z)
      
      Thanks for Max Bolinbroke for doing the hard work.
      
      In the end, instead of using two constructors in HsSyn, I used
      just one (still called ExplicitTuple) whose arguments can be
      	Present (LHsExpr id)
      or	Missing PostTcType
      
      While I was at it, I did a bit of refactoring too.
      58521c72
  15. 31 Jul, 2008 2 commits
  16. 04 May, 2008 1 commit
  17. 17 Jan, 2008 1 commit
  18. 20 Dec, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Implement generalised list comprehensions · 67cb4091
      simonpj@microsoft.com authored
        This patch implements generalised list comprehensions, as described in 
        the paper "Comprehensive comprehensions" (Peyton Jones & Wadler, Haskell
        Workshop 2007).  If you don't use the new comprehensions, nothing
        should change.
        
        The syntax is not exactly as in the paper; see the user manual entry 
        for details.
        
        You need an accompanying patch to the base library for this stuff 
        to work.
        
        The patch is the work of Max Bolingbroke [batterseapower@hotmail.com], 
        with some advice from Simon PJ.
        
        The related GHC Wiki page is 
          http://hackage.haskell.org/trac/ghc/wiki/SQLLikeComprehensions 
      67cb4091
  19. 10 Oct, 2007 1 commit
    • Dan Licata's avatar
      View patterns, record wildcards, and record puns · 6a05ec5e
      Dan Licata authored
      This patch implements three new features:
      * view patterns (syntax: expression -> pat in a pattern)
      * working versions of record wildcards and record puns
      See the manual for detailed descriptions.
      
      Other minor observable changes:
      * There is a check prohibiting local fixity declarations
        when the variable being fixed is not defined in the same let
      * The warn-unused-binds option now reports warnings for do and mdo stmts
      
      Implementation notes: 
      
      * The pattern renamer is now in its own module, RnPat, and the
      implementation is now in a CPS style so that the correct context is
      delivered to pattern expressions.
      
      * These features required a fairly major upheaval to the renamer.
      Whereas the old version used to collect up all the bindings from a let
      (or top-level, or recursive do statement, ...) and put them into scope
      before renaming anything, the new version does the collection as it
      renames.  This allows us to do the right thing with record wildcard
      patterns (which need to be expanded to see what names should be
      collected), and it allows us to implement the desired semantics for view
      patterns in lets.  This change had a bunch of domino effects brought on
      by fiddling with the top-level renaming.
      
      * Prior to this patch, there was a tricky bug in mkRecordSelId in HEAD,
      which did not maintain the invariant necessary for loadDecl.  See note
      [Tricky iface loop] for details.
      6a05ec5e
  20. 04 Sep, 2007 1 commit
  21. 03 Sep, 2007 2 commits
    • Ian Lynagh's avatar
      Use OPTIONS rather than OPTIONS_GHC for pragmas · ad94d409
      Ian Lynagh authored
      Older GHCs can't parse OPTIONS_GHC.
      This also changes the URL referenced for the -w options from
      WorkingConventions#Warnings to CodingStyle#Warnings for the compiler
      modules.
      ad94d409
    • Ross Paterson's avatar
      FIX for #1080 · 9630111a
      Ross Paterson authored
      Arrow desugaring now uses a private version of collectPatBinders and
      friends, in order to include dictionary bindings from ConPatOut.
      
      It doesn't fix arrowrun004 (#1333), though.
      9630111a
  22. 01 Sep, 2007 1 commit
  23. 02 Jul, 2007 1 commit
  24. 24 Apr, 2007 1 commit
    • Simon Marlow's avatar
      Breakpoints: get the names of the free variables right · 367b0590
      Simon Marlow authored
      Previously we relied on the names of the Ids attached to a tick being
      the same as the names of the original variables in the source code.
      Sometimes this worked, sometimes it didn't because the simplifier
      would inline away the Id.  So now we do this properly and retain the
      original OccNames from the source code for each breakpoint, and use
      these to construct the new Ids when we stop.
      
      Doing this involved moving the tracking of in-scope variables from the
      desugarer to the coverage pass.
      367b0590
  25. 25 Oct, 2006 1 commit
  26. 11 Oct, 2006 1 commit
    • Simon Marlow's avatar
      Module header tidyup, phase 1 · 49c98d14
      Simon Marlow authored
      This patch is a start on removing import lists and generally tidying
      up the top of each module.  In addition to removing import lists:
      
         - Change DATA.IOREF -> Data.IORef etc.
         - Change List -> Data.List etc.
         - Remove $Id$
         - Update copyrights
         - Re-order imports to put non-GHC imports last
         - Remove some unused and duplicate imports
      49c98d14
  27. 29 Sep, 2006 1 commit
  28. 20 Sep, 2006 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Complete the evidence generation for GADTs · 15cb792d
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:43:22 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Complete the evidence generation for GADTs
        Sat Aug  5 21:39:51 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Complete the evidence generation for GADTs
          Thu Jul 13 17:18:07 EDT 2006  simonpj@microsoft.com
            
            This patch completes FC evidence generation for GADTs.
            
            It doesn't work properly yet, because part of the compiler thinks
            	(t1 :=: t2) => t3
            is represented with FunTy/PredTy, while the rest thinks it's represented
            using ForAllTy.  Once that's done things should start to work.
      15cb792d
  29. 04 Aug, 2006 1 commit
  30. 07 Apr, 2006 1 commit
    • Simon Marlow's avatar
      Reorganisation of the source tree · 0065d5ab
      Simon Marlow authored
      Most of the other users of the fptools build system have migrated to
      Cabal, and with the move to darcs we can now flatten the source tree
      without losing history, so here goes.
      
      The main change is that the ghc/ subdir is gone, and most of what it
      contained is now at the top level.  The build system now makes no
      pretense at being multi-project, it is just the GHC build system.
      
      No doubt this will break many things, and there will be a period of
      instability while we fix the dependencies.  A straightforward build
      should work, but I haven't yet fixed binary/source distributions.
      Changes to the Building Guide will follow, too.
      0065d5ab
  31. 14 Oct, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-10-14 11:22:41 by simonpj] · 36436bc6
      simonpj authored
      Add record syntax for GADTs
      	~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Atrijus Tang wanted to add record syntax for GADTs and existential
      types, so he and I worked on it a bit at ICFP.  This commit is the
      result.  Now you can say
      
       data T a where
        T1 { x :: a }           	 :: T [a]
        T2 { x :: a, y :: Int } 	 :: T [a]
        forall b. Show b =>
       	T3 { naughty :: b, ok :: Int } :: T Int
        T4 :: Eq a => a -> b -> T (a,b)
      
      Here the constructors are declared using record syntax.
      
      Still to come after this commit:
        - User manual documentation
        - More regression tests
        - Some missing cases in the parser (e.g. T3 won't parse)
      Autrijus is going to do these.
      
      
      Here's a quick summary of the rules.  (Atrijus is going to write
      proper documentation shortly.)
      
      Defnition: a 'vanilla' constructor has a type of the form
      	forall a1..an. t1 -> ... -> tm -> T a1 ... an
      No existentials, no context, nothing.  A constructor declared with
      Haskell-98 syntax is vanilla by construction.  A constructor declared
      with GADT-style syntax is vanilla iff its type looks like the above.
      (In the latter case, the order of the type variables does not matter.)
      
      * You can mix record syntax and non-record syntax in a single decl
      
      * All constructors that share a common field 'x' must have the
        same result type (T [a] in the example).
      
      * You can use field names without restriction in record construction
        and record pattern matching.
      
      * Record *update* only works for data types that only have 'vanilla'
        constructors.
      
      * Consider the field 'naughty', which uses a type variable that does
        not appear in the result type ('b' in the example).  You can use the
        field 'naughty' in pattern matching and construction, but NO
        SELECTOR function is generated for 'naughty'.  [An attempt to use
        'naughty' as a selector function will elicit a helpful error
        message.]
      
      * Data types declared in GADT syntax cannot have a context. So this
      is illegal:
      	data (Monad m) => T a where
      		  ....
      
      * Constructors in GADT syntax can have a context (t.g. T3, T4 above)
        and that context is stored in the constructor and made available
        when the constructor is pattern-matched on.  WARNING: not competely
        implemented yet, but that's the plan.
      
      
      
      Implementation notes
      ~~~~~~~~~~~~~~~~~~~~
      - Data constructors (even vanilla ones) no longer share the type
        variables of their parent type constructor.
      
      - HsDecls.ConDecl has changed quite a bit
      
      - TyCons don't record the field labels and type any more (doesn't
        make sense for existential fields)
      
      - GlobalIdDetails records which selectors are 'naughty', and hence
        don't have real code.
      36436bc6
  32. 19 Jul, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-07-19 16:44:50 by simonpj] · a7ecdf96
      simonpj authored
      WARNING: this is a big commit.  You might want 
      	to wait a few days before updating, in case I've 
      	broken something.
      
      	However, if any of the changes are what you wanted,
      	please check it out and test!
      
      This commit does three main things:
      
      1. A re-organisation of the way that GHC handles bindings in HsSyn.
         This has been a bit of a mess for quite a while.  The key new
         types are
      
      	-- Bindings for a let or where clause
      	data HsLocalBinds id
      	  = HsValBinds (HsValBinds id)
      	  | HsIPBinds  (HsIPBinds id)
      	  | EmptyLocalBinds
      
      	-- Value bindings (not implicit parameters)
      	data HsValBinds id
      	  = ValBindsIn  -- Before typechecking
      		(LHsBinds id) [LSig id]	-- Not dependency analysed
      					-- Recursive by default
      
      	  | ValBindsOut	-- After typechecking
      		[(RecFlag, LHsBinds id)]-- Dependency analysed
      
      2. Implement Mark Jones's idea of increasing polymoprhism
         by using type signatures to cut the strongly-connected components
         of a recursive group.  As a consequence, GHC no longer insists
         on the contexts of the type signatures of a recursive group
         being identical.
      
         This drove a significant change: the renamer no longer does dependency
         analysis.  Instead, it attaches a free-variable set to each binding,
         so that the type checker can do the dep anal.  Reason: the typechecker
         needs to do *two* analyses:
      	one to find the true mutually-recursive groups
      		(which we need so we can build the right CoreSyn)
      	one to find the groups in which to typecheck, taking
      		account of type signatures
      
      3. Implement non-ground SPECIALISE pragmas, as promised, and as
         requested by Remi and Ross.  Certainly, this should fix the 
         current problem with GHC, namely that if you have
      	g :: Eq a => a -> b -> b
         then you can now specialise thus
      	SPECIALISE g :: Int -> b -> b
          (This didn't use to work.)
      
         However, it goes further than that.  For example:
      	f :: (Eq a, Ix b) => a -> b -> b
         then you can make a partial specialisation
      	SPECIALISE f :: (Eq a) => a -> Int -> Int
      
          In principle, you can specialise f to *any* type that is
          "less polymorphic" (in the sense of subsumption) than f's 
          actual type.  Such as
      	SPECIALISE f :: Eq a => [a] -> Int -> Int
          But I haven't tested that.
      
          I implemented this by doing the specialisation in the typechecker
          and desugarer, rather than leaving around the strange SpecPragmaIds,
          for the specialiser to find.  Indeed, SpecPragmaIds have vanished 
          altogether (hooray).
      
          Pragmas in general are handled more tidily.  There's a new
          data type HsBinds.Prag, which lives in an AbsBinds, and carries
          pragma info from the typechecker to the desugarer.
      
      
      Smaller things
      
      - The loop in the renamer goes via RnExpr, instead of RnSource.
        (That makes it more like the type checker.)
      
      - I fixed the thing that was causing 'check_tc' warnings to be 
        emitted.
      a7ecdf96
  33. 17 Apr, 2005 1 commit
  34. 04 Apr, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-04-04 11:55:11 by simonpj] · d551dbfe
      simonpj authored
      This commit combines three overlapping things:
      
      1.  Make rebindable syntax work for do-notation. The idea
          here is that, in particular, (>>=) can have a type that
          has class constraints on its argument types, e.g.
             (>>=) :: (Foo m, Baz a) => m a -> (a -> m b) -> m b
          The consequence is that a BindStmt and ExprStmt must have
          individual evidence attached -- previously it was one
          batch of evidence for the entire Do
          
          Sadly, we can't do this for MDo, because we use bind at
          a polymorphic type (to tie the knot), so we still use one
          blob of evidence (now in the HsStmtContext) for MDo.
          
          For arrow syntax, the evidence is in the HsCmd.
          
          For list comprehensions, it's all built-in anyway.
          
          So the evidence on a BindStmt is only used for ordinary
          do-notation.
      
      2.  Tidy up HsSyn.  In particular:
      
      	- Eliminate a few "Out" forms, which we can manage
      	without (e.g. 
      
      	- It ought to be the case that the type checker only
      	decorates the syntax tree, but doesn't change one
      	construct into another.  That wasn't true for NPat,
      	LitPat, NPlusKPat, so I've fixed that.
      
      	- Eliminate ResultStmts from Stmt.  They always had
      	to be the last Stmt, which led to awkward pattern
      	matching in some places; and the benefits didn't seem
      	to outweigh the costs.  Now each construct that uses
      	[Stmt] has a result expression too (e.g. GRHS).
      
      
      3.  Make 'deriving( Ix )' generate a binding for unsafeIndex,
          rather than for index.  This is loads more efficient.
      
          (This item only affects TcGenDeriv, but some of point (2)
          also affects TcGenDeriv, so it has to be in one commit.)
      d551dbfe
  35. 22 Dec, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-12-22 12:06:13 by simonpj] · d7c402a3
      simonpj authored
      ----------------------------------------
           New Core invariant: keep case alternatives in sorted order
      	----------------------------------------
      
      We now keep the alternatives of a Case in the Core language in sorted
      order.  Sorted, that is,
      	by constructor tag	for DataAlt
      	by literal		for LitAlt
      
      The main reason is that it makes matching and equality testing more robust.
      But in fact some lines of code vanished from SimplUtils.mkAlts.
      
      
      WARNING: no change to interface file formats, but you'll need to recompile
      your libraries so that they generate interface files that respect the
      invariant.
      d7c402a3
  36. 30 Sep, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-09-30 10:35:15 by simonpj] · 23f40f0e
      simonpj authored
      ------------------------------------
      	Add Generalised Algebraic Data Types
      	------------------------------------
      
      This rather big commit adds support for GADTs.  For example,
      
          data Term a where
       	  Lit :: Int -> Term Int
      	  App :: Term (a->b) -> Term a -> Term b
      	  If  :: Term Bool -> Term a -> Term a
      	  ..etc..
      
          eval :: Term a -> a
          eval (Lit i) = i
          eval (App a b) = eval a (eval b)
          eval (If p q r) | eval p    = eval q
          		    | otherwise = eval r
      
      
      Lots and lots of of related changes throughout the compiler to make
      this fit nicely.
      
      One important change, only loosely related to GADTs, is that skolem
      constants in the typechecker are genuinely immutable and constant, so
      we often get better error messages from the type checker.  See
      TcType.TcTyVarDetails.
      
      There's a new module types/Unify.lhs, which has purely-functional
      unification and matching for Type. This is used both in the typechecker
      (for type refinement of GADTs) and in Core Lint (also for type refinement).
      23f40f0e
  37. 15 Sep, 2004 1 commit
    • ross's avatar
      [project @ 2004-09-15 17:48:08 by ross] · daf67985
      ross authored
      arrow notation: allow arrow applications (f -< a) to take a non-empty
      command stack, as suggested by Sebastian Boldt <Sebastian.Boldt@arcor.de>.
      daf67985
  38. 17 Dec, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-12-17 11:29:40 by simonpj] · ca0b7c66
      simonpj authored
      -----------------------------------------------------
        Fix a subtle loop in the context-reduction machinery
        ----------------------------------------------------
      
      This bug was provoked by a recent change: when trying to prove
      a constraint C, TcSimplify.reduce now adds C to the database before
      trying to prove C, thus building recursive dictionaries.
      
      Two bugs
      a) If we add C's superclasses (which we were) we can now build a
         bogusly-recursive dictionary (see Note [SUPERCLASS-LOOP]).
         Solution: in reduce, add C only (via addIrred NoSCs) and then
         later use addWanted to add its definition plus SCs.
      
      b) Since we can have recursive definitions, the superclass-loop
         handling machinery (findAllDeps) must carry its visited-set
         with it (which it was not doing before)
      
      
      The main file is TcSimplify; but I modified a bunch of others to
      take advantage of new function extendVarSetList
      ca0b7c66