shithub: MicroHs

Download patch

ref: 0e831c79ddcf05d4a53ae2c76a3d3d126aee5141
parent: c8933c077bc49864bf6dce8d021f5f8c6fc4aa9e
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Sat Aug 17 15:47:49 EDT 2024

Function to get module name.

--- a/src/MicroHs/Ident.hs
+++ b/src/MicroHs/Ident.hs
@@ -11,6 +11,7 @@
   dummyIdent, isDummyIdent,
   unQualIdent,
   unQualString,
+  qualOf,
   addIdentSuffix,
   SLoc(..), noSLoc,
   showSLoc,
@@ -20,6 +21,7 @@
 import Data.Char
 import Text.PrettyPrint.HughesPJLite
 import GHC.Stack
+import MicroHs.List(dropEnd)
 
 type Line = Int
 type Col  = Int
@@ -91,6 +93,9 @@
 
 unQualIdent :: Ident -> Ident
 unQualIdent (Ident l s) = Ident l (unQualString s)
+
+qualOf :: Ident -> Ident
+qualOf (Ident loc s) = Ident loc (dropEnd (length (unQualString s) + 1) s)
 
 isConIdent :: Ident -> Bool
 isConIdent (Ident _ i) =
--