@@ -36,6 +36,8 @@ import Language.Haskell.Exts.SrcLoc
3636import Language.Haskell.Exts.Syntax
3737import Language.Haskell.Generate.Expression
3838
39+import Prelude
40+
3941--------------------------------------------------------------------------------
4042-- Generate expressions
4143
@@ -62,9 +64,11 @@ generateExp = prettyPrint . runExpression . fst . runGenerate
6264caseE :: ExpG x -> [(Pat, ExpG t)] -> ExpG t
6365caseE v alt = do
6466 v' <- v
65−#if MIN_VERSION_haskell_src_exts(1,16,0)
67+#if MIN_VERSION_haskell_src_exts(1,17,0)
68+ alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') Nothing) a) alt
69+#elif MIN_VERSION_haskell_src_exts(1,16,0)
6670 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') (BDecls [])) a) alt
67−#else
71+#else
6872 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedAlt $ runExpression a') (BDecls [])) a) alt
6973#endif
7074 return $ Expression $ Case (runExpression v') alt'
@@ -210,7 +214,7 @@ instance GenExp (FunRef t) where
210214
211215-- | Generate a ExportSpec for a given function item.
212216exportFun :: FunRef t -> ExportSpec
213−#if MIN_VERSION_haskell_src_exts(1,16,0)
217+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0)
214218exportFun (FunRef name) = EVar NoNamespace (UnQual name)
215219#else
216220exportFun (FunRef name) = EVar (UnQual name)
@@ -220,7 +224,11 @@ exportFun (FunRef name) = EVar (UnQual name)
220224addDecl :: Name -> ExpG t -> ModuleM (FunRef t)
221225addDecl name e = ModuleM $ do
222226 let (body, mods) = runGenerate e
227+#if MIN_VERSION_haskell_src_exts(1,17,0)
228+ tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) Nothing]])
229+#else
223230 tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) $ BDecls []]])
231+#endif
224232 return $ FunRef name
225233
226234-- | Extract the Module from a module generator.