1. 28 Dec, 2001 4 commits
    • simonpj's avatar
      [project @ 2001-12-28 17:25:31 by simonpj] · ae969b47
      simonpj authored
      ---------------------
      	Dealing with deriving
      	---------------------
      
      I spent a ridiculously long time peering at a bug report whereby
      a 'deriving' clause sent GHC 5.02.1 into a loop.  It was all to
      do with allowing instances like
      
      	instance Foo a b => Baz (T a)
      
      (Notice the 'b' on the left which does not appear on the right.)
      
      I realised that it's hard for the deriving machinery to find a
      fixpoint when these sort of instance decls are around.  So I
      now constrain *derived* instance decls not to have this form;
      all the tyvars on the left must appear on the right.
      
      On the way I commoned up the previously-separate tcSimplify
      machinery for 'deriving' and 'default' decls with that for
      everything else.   As a result, quite a few files are touched.
      
      I hope I havn't broken anything.
      ae969b47
    • simonpj's avatar
      [project @ 2001-12-28 17:20:36 by simonpj] · 246dab8d
      simonpj authored
      -----------------------------
      	Buglet in rank-N polymorphism
      	-----------------------------
      
      Fix a bug in the way result type signatures are handled; they
      hadn't been brought into the rank-N polymorphism world.
      246dab8d
    • sof's avatar
      [project @ 2001-12-28 16:36:54 by sof] · 210d594c
      sof authored
      heal
      210d594c
    • sof's avatar
      [project @ 2001-12-28 00:14:33 by sof] · 9c77e2dc
      sof authored
      debugging-by-nightly-build-reports; give poke_c_flag a correct FI decl
      9c77e2dc
  2. 27 Dec, 2001 3 commits
    • sof's avatar
      [project @ 2001-12-27 11:29:58 by sof] · d6977670
      sof authored
      Get rid of uses of #const, #peek, #poke and #ptr from PrelPosix.hsc
      (this leaves just uses of #type in PrelPosix) - provide constant and
      accessor wrappers via PrelIOUtils.c instead.
      
      Who knows, we might just be able to bootstrap via .hc files again..?
      
      Only compiled & tested under Win32.
      d6977670
    • sof's avatar
      [project @ 2001-12-27 11:26:03 by sof] · 14b9c05f
      sof authored
      Added & exported low-level memcpy() wrappers - possible to offset both
      src and dest.
      14b9c05f
    • sof's avatar
      [project @ 2001-12-27 09:28:10 by sof] · 215280e9
      sof authored
      - removed PrelPosix.c_read, PrelPosix.c_write
      - added Ptr and RawBuffer versions of PrelHandle.write_off,
        and PrelHandle.read_off and exported them, i.e., PrelHandle
        now exports:
      
          read_off_ba :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
          read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
          write_off_ba :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
          write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
      
      - make hPutChar (win)socket friendly.
      215280e9
  3. 26 Dec, 2001 1 commit
  4. 21 Dec, 2001 6 commits
  5. 20 Dec, 2001 8 commits
    • sewardj's avatar
      [project @ 2001-12-20 17:38:40 by sewardj] · fd37eea4
      sewardj authored
      Move some small inline-in-C functions out of PrelPosix.hsc and into
      the supporting cbits sources, where they belong.
      
      Following this change, can you now compile the entire Prelude on
      x86-linux with the native code generator, and get something which
      actually works properly.
      fd37eea4
    • simonpj's avatar
      [project @ 2001-12-20 17:10:00 by simonpj] · f3695b15
      simonpj authored
      Wibbles
      f3695b15
    • simonpj's avatar
      [project @ 2001-12-20 17:09:46 by simonpj] · e8e3d264
      simonpj authored
      Comments
      e8e3d264
    • simonmar's avatar
      [project @ 2001-12-20 16:39:29 by simonmar] · 09355297
      simonmar authored
      Now that we can derive arbitrary classes for newtypes, use this to
      derive all the classes we need for the types in PrelCTypes and
      PrelCTypesISO, instead of the previous hack of explicitly coercing the
      methods.
      
      This should improve the quality of code using these types too; the
      coercions were surely getting in the way of optimisations before.
      09355297
    • sewardj's avatar
      [project @ 2001-12-20 16:12:09 by sewardj] · 791d890c
      sewardj authored
      Outline freeStablePtr, so NCG-generated code actually has something to call :)
      
      Also remove the presumably-defunct splitStablePtr.
      791d890c
    • sewardj's avatar
      [project @ 2001-12-20 15:20:37 by sewardj] · 0cc54eac
      sewardj authored
      Generate floating-point comparisons on x86 which deal with NaNs in what
      I assume is an IEEE854 compliant fashion.  For
         == >= > <= <
      if either arg is a NaN, produce False, and for
         /=
      if either arg is a NaN, produce True.
      
      This is the behaviour that gcc has, by default.
      
      Requires some ultramagical x86 code frags to be emitted.  A big comment
      in PprMach explains how it works.
      0cc54eac
    • sewardj's avatar
      [project @ 2001-12-20 15:16:13 by sewardj] · 5aaf7975
      sewardj authored
      nano-comment-wibble
      5aaf7975
    • simonpj's avatar
      [project @ 2001-12-20 11:19:05 by simonpj] · 91c750cb
      simonpj authored
      ---------------------------------------------
      	More type system extensions (for John Hughes)
      	---------------------------------------------
      
      1.  Added a brand-new extension that lets you derive ARBITRARY CLASSES
      for newtypes.  Thus
      
      	newtype Age = Age Int deriving( Eq, Ord, Shape, Ix )
      
      The idea is that the dictionary for the user-defined class Shape Age
      is *identical* to that for Shape Int, so there is really no deriving
      work to do.   This saves you writing the very tiresome instance decl:
      
      	instance Shape Age where
      	   shape_op1 (Age x) = shape_op1 x
      	   shape_op2 (Age x1) (Age x2) = shape_op2 x1 x2
      	   ...etc...
      
      It's more efficient, too, becuase the Shape Age dictionary really
      will be identical to the Shape Int dictionary.
      
      There's an exception for Read and Show, because the derived instance
      *isn't* the same.
      
      There is a complication where higher order stuff is involved.  Here is
      the example John gave:
      
         class StateMonad s m | m -> s where ...
      
         newtype Parser tok m a = Parser (State [tok] (Failure m) a)
      			  deriving( Monad, StateMonad )
      
      Then we want the derived instance decls to be
      
         instance Monad (State [tok] (Failure m)) => Monad (Parser tok m)
         instance StateMonad [tok] (State [tok] (Failure m))
      	 => StateMonad [tok] (Parser tok m)
      
      John is writing up manual entry for all of this, but this commit
      implements it.   I think.
      
      
      2.  Added -fallow-incoherent-instances, and documented it.  The idea
      is that sometimes GHC is over-protective about not committing to a
      particular instance, and the programmer may want to say "commit anyway".
      Here's the example:
      
          class Sat a where
            dict :: a
      
          data EqD a = EqD {eq :: a->a->Bool}
      
          instance Sat (EqD a) => Eq a where
            (==) = eq dict
      
          instance Sat (EqD Integer) where
            dict = EqD{eq=(==)}
      
          instance Eq a => Sat (EqD a) where
            dict = EqD{eq=(==)}
      
          class Collection c cxt | c -> cxt where
            empty :: Sat (cxt a) => c a
            single :: Sat (cxt a) => a -> c a
            union :: Sat (cxt a) => c a -> c a -> c a
            member :: Sat (cxt a) => a -> c a -> Bool
      
          instance Collection [] EqD where
            empty = []
            single x = [x]
            union = (++)
            member = elem
      
      It's an updated attempt to model "Restricted Data Types", if you
      remember my Haskell workshop paper. In the end, though, GHC rejects
      the program (even with fallow-overlapping-instances and
      fallow-undecideable-instances), because there's more than one way to
      construct the Eq instance needed by elem.
      
      Yet all the ways are equivalent! So GHC is being a bit over-protective
      of me, really: I know what I'm doing and I would LIKE it to pick an
      arbitrary one. Maybe a flag fallow-incoherent-instances would be a
      useful thing to add?
      91c750cb
  6. 19 Dec, 2001 3 commits
  7. 18 Dec, 2001 8 commits
  8. 17 Dec, 2001 6 commits
  9. 15 Dec, 2001 1 commit