on master help sign in
Handle Default Language specifications
commit154973fe486d0ef9757ed95cbad183d1caae9edb authorleon.smith@obsidian.systems <leon.smith@obsidian.systems> dateFri 17 Jan 2020, 12:47 (7 years ago) parentd6cbbf7
1 file changed+8−2
lib/command/src/Obelisk/Command/Preprocessor.hs+8−2
lib/command/src/Obelisk/Command/Preprocessor.hs+8−2
@@ -10,7 +10,7 @@ import Data.Maybe (fromMaybe)
1010import qualified Data.Text.Lazy.Builder as TL
1111import qualified Data.Text.Lazy.Encoding as TL
1212import Distribution.Compiler (CompilerFlavor (..))
13−import Language.Haskell.Extension (Extension (..))
13+import Language.Haskell.Extension (Extension (..), Language(..))
1414import System.IO (IOMode (..), hClose, hPutStrLn, openFile, stderr)
1515import System.FilePath (hasTrailingPathSeparator, joinPath, normalise, splitPath)
1616
@@ -68,7 +68,13 @@ generateHeader origPath packageInfo =
6868 <> mconcat (intersperse (TL.fromText ", ") extList)
6969 <> TL.fromText " #-}\n"
7070 else mempty
71− extList = concatMap showExt (_cabalPackageInfo_defaultExtensions packageInfo)
71+ extList = addDefaultLanguage $ concatMap showExt $ _cabalPackageInfo_defaultExtensions packageInfo
72+ addDefaultLanguage =
73+ case _cabalPackageInfo_defaultLanguage packageInfo of
74+ Nothing -> id
75+ Just x -> case x of
76+ UnknownLanguage ext -> ( TL.fromString ext :)
77+ ext -> ( TL.fromString (show ext) :)
7278 showExt = \case
7379 EnableExtension ext -> [TL.fromString (show ext)]
7480 DisableExtension _ -> []