Skip to content

Instantly share code, notes, and snippets.

@rpglover64
Last active December 17, 2015 21:10
Show Gist options
  • Save rpglover64/5673117 to your computer and use it in GitHub Desktop.
Save rpglover64/5673117 to your computer and use it in GitHub Desktop.
Patch removing -fglasgow-exts
From ee58a991f599b4cae769ece59a86c9afcf7ec0e9 Mon Sep 17 00:00:00 2001
From: Alex Rozenshteyn <rpglover64@gmail.com>
Date: Wed, 29 May 2013 15:25:05 -0400
Subject: [PATCH 1/2] foo
---
source/src/BNFC/Backend/HaskellGADT.hs | 2 +-
source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs | 2 +-
source/src/BNFC/Backend/HaskellGADT/CFtoPrinterGADT.hs | 2 +-
source/src/BNFC/Backend/HaskellGADT/CFtoTemplateGADT.hs | 1 +
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/source/src/BNFC/Backend/HaskellGADT.hs b/source/src/BNFC/Backend/HaskellGADT.hs
index b1d7fb9..1ddb06b 100644
--- a/source/src/BNFC/Backend/HaskellGADT.hs
+++ b/source/src/BNFC/Backend/HaskellGADT.hs
@@ -237,7 +237,7 @@ lift_parser
composOp :: String -> String
composOp composOpMod = unlines
[
- "{-# OPTIONS_GHC -fglasgow-exts #-}",
+ "{-# LANGUAGE Rank2Types#-}",
"module " ++ composOpMod ++ " (Compos(..),composOp,composOpM,composOpM_,composOpMonoid,",
" composOpMPlus,composOpFold) where",
"",
diff --git a/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs b/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs
index 61079cf..ad5c991 100644
--- a/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs
+++ b/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs
@@ -30,7 +30,7 @@ import Data.Maybe (catMaybes)
-- to produce a Haskell module
cf2Abstract :: Bool -> String -> CF -> String -> String
cf2Abstract byteStrings name cf composOpMod = unlines $ [
- "{-# OPTIONS_GHC -fglasgow-exts #-}",
+ "{-# LANGUAGE GADTs, KindSignatures #-}",
"module" +++ name +++ "(" ++ concat (intersperse ", " exports) ++ ")" +++ "where",
"",
"import " ++ composOpMod,
diff --git a/source/src/BNFC/Backend/HaskellGADT/CFtoPrinterGADT.hs b/source/src/BNFC/Backend/HaskellGADT/CFtoPrinterGADT.hs
index e7172f5..0a9970a 100644
--- a/source/src/BNFC/Backend/HaskellGADT/CFtoPrinterGADT.hs
+++ b/source/src/BNFC/Backend/HaskellGADT/CFtoPrinterGADT.hs
@@ -39,7 +39,7 @@ cf2Printer name absMod cf = unlines $ [
prologue :: String -> String -> String
prologue name absMod = unlines [
- "{-# OPTIONS_GHC -fglasgow-exts #-}",
+ "{-# LANGUAGE GADTs, TypeSynonymInstances, FlexibleInstances #-}",
"module " ++ name +++ "where\n",
"-- pretty-printer generated by the BNF converter\n",
"import " ++ absMod,
diff --git a/source/src/BNFC/Backend/HaskellGADT/CFtoTemplateGADT.hs b/source/src/BNFC/Backend/HaskellGADT/CFtoTemplateGADT.hs
index 0085e4c..62aa3ec 100644
--- a/source/src/BNFC/Backend/HaskellGADT/CFtoTemplateGADT.hs
+++ b/source/src/BNFC/Backend/HaskellGADT/CFtoTemplateGADT.hs
@@ -33,6 +33,7 @@ type ModuleName = String
cf2Template :: ModuleName -> ModuleName -> ModuleName -> CF -> String
cf2Template skelName absName errName cf = unlines $
[
+ "{-# LANGUAGE GADTs #-}",
"module "++ skelName ++ " where",
"",
"-- Haskell module generated by the BNF converter",
--
1.8.2.3
From e03e6d9982d9a1444ef720cbfa912bd42b37643d Mon Sep 17 00:00:00 2001
From: Alex Rozenshteyn <rpglover64@gmail.com>
Date: Wed, 29 May 2013 17:17:46 -0400
Subject: [PATCH 2/2] bar
---
source/src/BNFC/Backend/HaskellGADT.hs | 2 +-
source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/source/src/BNFC/Backend/HaskellGADT.hs b/source/src/BNFC/Backend/HaskellGADT.hs
index 1ddb06b..360173b 100644
--- a/source/src/BNFC/Backend/HaskellGADT.hs
+++ b/source/src/BNFC/Backend/HaskellGADT.hs
@@ -237,7 +237,7 @@ lift_parser
composOp :: String -> String
composOp composOpMod = unlines
[
- "{-# LANGUAGE Rank2Types#-}",
+ "{-# LANGUAGE Rank2Types, PolyKinds #-}",
"module " ++ composOpMod ++ " (Compos(..),composOp,composOpM,composOpM_,composOpMonoid,",
" composOpMPlus,composOpFold) where",
"",
diff --git a/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs b/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs
index ad5c991..b764b3a 100644
--- a/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs
+++ b/source/src/BNFC/Backend/HaskellGADT/CFtoAbstractGADT.hs
@@ -21,7 +21,7 @@ module BNFC.Backend.HaskellGADT.CFtoAbstractGADT (cf2Abstract) where
import BNFC.CF
import BNFC.Utils((+++),(++++))
-import Data.List(intersperse,nub)
+import Data.List(intersperse,intercalate,nub)
import BNFC.Backend.HaskellGADT.HaskellGADTCommon
@@ -30,7 +30,7 @@ import Data.Maybe (catMaybes)
-- to produce a Haskell module
cf2Abstract :: Bool -> String -> CF -> String -> String
cf2Abstract byteStrings name cf composOpMod = unlines $ [
- "{-# LANGUAGE GADTs, KindSignatures #-}",
+ "{-# LANGUAGE GADTs, KindSignatures, DataKinds #-}",
"module" +++ name +++ "(" ++ concat (intersperse ", " exports) ++ ")" +++ "where",
"",
"import " ++ composOpMod,
@@ -60,16 +60,17 @@ getTreeCats :: CF -> [String]
getTreeCats cf = nub $ filter (not . isList) $ map consCat $ cf2cons cf
prDummyTypes :: CF -> [String]
-prDummyTypes cf = concatMap prDummyType $ getTreeCats cf
+prDummyTypes cf = [prDummyData] ++ map prDummyType cats
where
- prDummyType cat = ["data" +++ t, "type" +++ cat +++ "= Tree" +++ t ]
- where t = mkRealType cat
+ cats = getTreeCats cf
+ prDummyData = "data Tag =" +++ intercalate " | " (map mkRealType cats)
+ prDummyType cat = "type" +++ cat +++ "= Tree" +++ mkRealType cat
mkRealType :: Cat -> String
mkRealType cat = cat ++ "_" -- FIXME: make sure that there is no such category already
prTreeType :: Bool -> CF -> [String]
-prTreeType byteStrings cf = ["data Tree :: * -> * where"] ++ map ((" "++) . prTreeCons) (cf2cons cf)
+prTreeType byteStrings cf = ["data Tree :: Tag -> * where"] ++ map ((" "++) . prTreeCons) (cf2cons cf)
where
prTreeCons c
| isPositionCat cf cat = fun +++ ":: ((Int,Int),"++stringType++") -> Tree" +++ mkRealType cat
--
1.8.2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment