ref: 9ebefcdc1b90b9e0e773b9b8f1afd01ac55c2a64
parent: 802354a60d9537547fd2d55d6bd48310bddb7b86
author: Lennart Augustsson <lennart@augustsson.net>
date: Sun Sep 1 04:49:10 EDT 2024
Keep Ident abstract.
--- a/ghc/MicroHs/Instances.hs
+++ b/ghc/MicroHs/Instances.hs
@@ -13,7 +13,9 @@
instance NFData Lit where rnf (LInt i) = rnf i; rnf (LInteger i) = rnf i; rnf (LDouble d) = rnf d; rnf (LRat r) = rnf r; rnf (LChar c) = rnf c; rnf (LStr s) = rnf s; rnf (LPrim s) = rnf s; rnf (LExn s) = rnf s; rnf (LForImp s _) = rnf s; rnf (LTick s) = rnf s; rnf (LUStr s) = rnf s
-instance NFData Ident where rnf (Ident _ s) = rnf s
+instance NFData SLoc where rnf (SLoc f l c) = rnf f `seq` rnf l `seq` rnf c
+
+instance NFData Ident where rnf i = rnf (slocIdent i)
compiledWithGHC :: Bool
compiledWithGHC = True
--- a/src/MicroHs/Expr.hs
+++ b/src/MicroHs/Expr.hs
@@ -328,7 +328,7 @@
getSLoc :: a -> SLoc
instance HasLoc Ident where
- getSLoc (Ident l _) = l
+ getSLoc = slocIdent
-- Approximate location; only identifiers and literals carry a location
instance HasLoc Expr where
--- a/src/MicroHs/Ident.hs
+++ b/src/MicroHs/Ident.hs
@@ -2,7 +2,7 @@
-- See LICENSE file for full license.
module MicroHs.Ident(
Line, Col,
- Ident(..),
+ Ident,
mkIdent, unIdent, isIdent,
qualIdent, showIdent, setSLocIdent,
ppIdent,
@@ -9,6 +9,7 @@
mkIdentSLoc,
isLower_, isIdentChar, isOperChar, isConIdent,
dummyIdent, isDummyIdent,
+ slocIdent,
headIdent,
unQualIdent,
unQualString,
@@ -49,6 +50,9 @@
instance Show Ident where
show = showIdent
+
+slocIdent :: Ident -> SLoc
+slocIdent (Ident l _) = l
noSLoc :: SLoc
noSLoc = SLoc "" 0 0
--
⑨