Commit eb256640 authored by Jan Stolarek's avatar Jan Stolarek
Browse files

Comparison primops return Int# (Fixes #6135)

For a deatiled discussion of this changes please visit the wiki page:
http://hackage.haskell.org/trac/ghc/wiki/PrimBool
parent bdde811a
......@@ -411,7 +411,7 @@ data STArray s i e
-- Just pointer equality on mutable arrays:
instance Eq (STArray s i e) where
STArray _ _ _ arr1# == STArray _ _ _ arr2# =
sameMutableArray# arr1# arr2#
tagToEnum# (sameMutableArray# arr1# arr2#)
\end{code}
......
......@@ -11,11 +11,15 @@ The overall structure of the GHC Prelude is a bit tricky.
So the rough structure is as follows, in (linearised) dependency order
GHC.Prim Has no implementation. It defines built-in things, and
GHC.Prim Has no implementation. It defines built-in things, and
by importing it you bring them into scope.
The source file is GHC.Prim.hi-boot, which is just
copied to make GHC.Prim.hi
GHC.PrimWrappers
Provides wrappers for built-in comparison operators.
These wrappers take unboxed operands and return a Bool.
GHC.Base Classes: Eq, Ord, Functor, Monad
Types: list, (), Int, Bool, Ordering, Char, String
......@@ -101,8 +105,9 @@ module GHC.Base
module GHC.CString,
module GHC.Magic,
module GHC.Types,
module GHC.Prim, -- Re-export GHC.Prim and [boot] GHC.Err, to avoid lots
module GHC.Err -- of people having to import it explicitly
module GHC.Prim, -- Re-export GHC.Prim, GHC.PrimWrappers and
module GHC.PrimWrappers,-- [boot] GHC.Err, to avoid lots of people having to
module GHC.Err -- import it explicitly
)
where
......@@ -112,6 +117,7 @@ import GHC.CString
import GHC.Magic
import GHC.Prim
import GHC.Err
import GHC.PrimWrappers
import {-# SOURCE #-} GHC.IO (failIO)
-- This is not strictly speaking required by this module, but is an
......@@ -734,4 +740,3 @@ a `iShiftRL#` b | b >=# WORD_SIZE_IN_BITS# = 0#
data RealWorld
\end{code}
#endif
......@@ -676,7 +676,7 @@ data TVar a = TVar (TVar# RealWorld a)
INSTANCE_TYPEABLE1(TVar,tvarTc,"TVar")
instance Eq (TVar a) where
(TVar tvar1#) == (TVar tvar2#) = sameTVar# tvar1# tvar2#
(TVar tvar1#) == (TVar tvar2#) = tagToEnum# (sameTVar# tvar1# tvar2#)
-- |Create a new TVar holding a value supplied
newTVar :: a -> STM (TVar a)
......
......@@ -28,6 +28,7 @@ module GHC.Exts
-- * Primitive operations
module GHC.Prim,
module GHC.PrimWrappers,
shiftL#, shiftRL#, iShiftL#, iShiftRA#, iShiftRL#,
uncheckedShiftL64#, uncheckedShiftRL64#,
uncheckedIShiftL64#, uncheckedIShiftRA64#,
......@@ -66,6 +67,7 @@ module GHC.Exts
import Prelude
import GHC.Prim
import GHC.PrimWrappers
import GHC.Base
import GHC.Word
import GHC.Int
......
......@@ -45,7 +45,7 @@ as a a box, which may be empty or full.
-- pull in Eq (Mvar a) too, to avoid GHC.Conc being an orphan-instance module
instance Eq (MVar a) where
(MVar mvar1#) == (MVar mvar2#) = sameMVar# mvar1# mvar2#
(MVar mvar1#) == (MVar mvar2#) = tagToEnum# (sameMVar# mvar1# mvar2#)
{-
M-Vars are rendezvous points for concurrent threads. They begin
......
......@@ -385,27 +385,31 @@ instance Real Integer where
instance Integral Integer where
toInteger n = n
{-# INLINE quot #-}
_ `quot` 0 = divZeroError
n `quot` d = n `quotInteger` d
{-# INLINE rem #-}
_ `rem` 0 = divZeroError
n `rem` d = n `remInteger` d
n `rem` d = n `remInteger` d
{-# INLINE div #-}
_ `div` 0 = divZeroError
n `div` d = n `divInteger` d
{-# INLINE mod #-}
_ `mod` 0 = divZeroError
n `mod` d = n `modInteger` d
n `mod` d = n `modInteger` d
{-# INLINE divMod #-}
_ `divMod` 0 = divZeroError
a `divMod` b = case a `divModInteger` b of
(# x, y #) -> (x, y)
n `divMod` d = case n `divModInteger` d of
(# x, y #) -> (x, y)
{-# INLINE quotRem #-}
_ `quotRem` 0 = divZeroError
a `quotRem` b = case a `quotRemInteger` b of
(# q, r #) -> (q, r)
-- use the defaults for div & mod
n `quotRem` d = case n `quotRemInteger` d of
(# q, r #) -> (q, r)
\end{code}
......
......@@ -48,6 +48,6 @@ writeSTRef (STRef var#) val = ST $ \s1# ->
-- Just pointer equality on mutable references:
instance Eq (STRef s a) where
STRef v1# == STRef v2# = sameMutVar# v1# v2#
STRef v1# == STRef v2# = tagToEnum# (sameMutVar# v1# v2#)
\end{code}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment