[Git][ghc/ghc][wip/romes/ttg-zurich] AST: Moved definitions that use GHC.Utils.Panic to GHC namespace
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Sun Jun 9 17:18:44 UTC 2024
Rodrigo Mesquita pushed to branch wip/romes/ttg-zurich at Glasgow Haskell Compiler / GHC
Commits:
68abf0c8 by Mauricio at 2024-06-09T19:18:36+02:00
AST: Moved definitions that use GHC.Utils.Panic to GHC namespace
Progress towards #21592
- - - - -
2 changed files:
- compiler/GHC/Hs/Lit.hs
- compiler/Language/Haskell/Syntax/Lit.hs
Changes:
=====================================
compiler/GHC/Hs/Lit.hs
=====================================
@@ -35,6 +35,7 @@ import GHC.Hs.Extension
import Language.Haskell.Syntax.Expr ( HsExpr )
import Language.Haskell.Syntax.Extension
import Language.Haskell.Syntax.Lit
+import GHC.Utils.Panic (panic)
{-
************************************************************************
@@ -253,3 +254,15 @@ negateOverLitVal :: OverLitVal -> OverLitVal
negateOverLitVal (HsIntegral i) = HsIntegral (negateIntegralLit i)
negateOverLitVal (HsFractional f) = HsFractional (negateFractionalLit f)
negateOverLitVal _ = panic "negateOverLitVal: argument is not a number"
+
+instance (Ord (XXOverLit p)) => Ord (HsOverLit p) where
+ compare (OverLit _ val1) (OverLit _ val2) = val1 `compare` val2
+ compare (XOverLit val1) (XOverLit val2) = val1 `compare` val2
+ compare _ _ = panic "Ord HsOverLit"
+
+-- Comparison operations are needed when grouping literals
+-- for compiling pattern-matching (module GHC.HsToCore.Match.Literal)
+instance (Eq (XXOverLit p)) => Eq (HsOverLit p) where
+ (OverLit _ val1) == (OverLit _ val2) = val1 == val2
+ (XOverLit val1) == (XOverLit val2) = val1 == val2
+ _ == _ = panic "Eq HsOverLit"
=====================================
compiler/Language/Haskell/Syntax/Lit.hs
=====================================
@@ -20,7 +20,6 @@ module Language.Haskell.Syntax.Lit where
import Language.Haskell.Syntax.Extension
-import GHC.Utils.Panic (panic)
import GHC.Types.SourceText (IntegralLit, FractionalLit, SourceText)
import GHC.Core.Type (Type)
@@ -128,24 +127,12 @@ data OverLitVal
| HsIsString !SourceText !FastString -- ^ String-looking literals
deriving Data
--- Comparison operations are needed when grouping literals
--- for compiling pattern-matching (module GHC.HsToCore.Match.Literal)
-instance (Eq (XXOverLit p)) => Eq (HsOverLit p) where
- (OverLit _ val1) == (OverLit _ val2) = val1 == val2
- (XOverLit val1) == (XOverLit val2) = val1 == val2
- _ == _ = panic "Eq HsOverLit"
-
instance Eq OverLitVal where
(HsIntegral i1) == (HsIntegral i2) = i1 == i2
(HsFractional f1) == (HsFractional f2) = f1 == f2
(HsIsString _ s1) == (HsIsString _ s2) = s1 == s2
_ == _ = False
-instance (Ord (XXOverLit p)) => Ord (HsOverLit p) where
- compare (OverLit _ val1) (OverLit _ val2) = val1 `compare` val2
- compare (XOverLit val1) (XOverLit val2) = val1 `compare` val2
- compare _ _ = panic "Ord HsOverLit"
-
instance Ord OverLitVal where
compare (HsIntegral i1) (HsIntegral i2) = i1 `compare` i2
compare (HsIntegral _) (HsFractional _) = LT
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68abf0c8cb2aa9e17e2dcf7e1fe1126437753172
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68abf0c8cb2aa9e17e2dcf7e1fe1126437753172
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240609/968ecc35/attachment-0001.html>
More information about the ghc-commits
mailing list