shithub: MicroHs

Download patch

ref: 216898a5ca91bcea3a6a136cc707c8825c9a797d
parent: 888a3f867924137c4895f5c1627d74943b3e80ec
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Thu Nov 23 08:53:40 EST 2023

Parse and ignore deriving.

--- a/src/MicroHs/Parse.hs
+++ b/src/MicroHs/Parse.hs
@@ -119,7 +119,7 @@
 
 keywords :: [String]
 keywords =
-  ["case", "class", "data", "default", "do", "else", "forall", "foreign", "if",
+  ["case", "class", "data", "default", "deriving", "do", "else", "forall", "foreign", "if",
    "import", "in", "infix", "infixl", "infixr", "instance",
    "let", "module", "newtype", "of", "primitive", "then", "type", "where"]
 
@@ -252,8 +252,8 @@
 pDef :: P EDef
 pDef =
       Data        <$> (pKeyword "data"    *> pLHS) <*> ((pSymbol "=" *> esepBy1 pConstr (pSymbol "|"))
-                                                        <|< pure [])
-  <|< Newtype     <$> (pKeyword "newtype" *> pLHS) <*> (pSymbol "=" *> (Constr [] [] <$> pUIdentSym <*> pField))
+                                                        <|< pure []) <* pDeriving
+  <|< Newtype     <$> (pKeyword "newtype" *> pLHS) <*> (pSymbol "=" *> (Constr [] [] <$> pUIdentSym <*> pField)) <* pDeriving
   <|< Type        <$> (pKeyword "type"    *> pLHS) <*> (pSymbol "=" *> pType)
   <|< uncurry Fcn <$> pEqns
   <|< Sign        <$> (pLIdentSym <* pSymbol "::") <*> pType
@@ -275,6 +275,10 @@
       fs <- pFields
       guard $ either length length fs == 1
       pure fs
+
+-- deriving is parsed, but ignored
+pDeriving :: P [EType]
+pDeriving = pKeyword "deriving" *> pParens (esepBy pType (pSpec ',')) <|< pure []
 
 pContext :: P [EConstraint]
 pContext = (pCtx <* pSymbol "=>") <|< pure []
--