[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
Mon Jun 10 08:18:18 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/ttg-zurich at Glasgow Haskell Compiler / GHC


Commits:
11873fd4 by Mauricio at 2024-06-10T10:14:49+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
=====================================
@@ -253,3 +253,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/11873fd4e5113185fe2f0880da00f6b2b2c3971f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/11873fd4e5113185fe2f0880da00f6b2b2c3971f
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/20240610/2bcc09c3/attachment-0001.html>


More information about the ghc-commits mailing list