@@ -36,6 +36,8 @@ import Language.Haskell.Exts.SrcLoc
36import Language.Haskell.Exts.Syntax
36import Language.Haskell.Exts.Syntax
37import Language.Haskell.Generate.Expression
37import Language.Haskell.Generate.Expression
39--------------------------------------------------------------------------------
41--------------------------------------------------------------------------------
40-- Generate expressions
42-- Generate expressions
@@ -62,9 +64,11 @@ generateExp = prettyPrint . runExpression . fst . runGenerate
62caseE :: ExpG x -> [(Pat, ExpG t)] -> ExpG t
64caseE :: ExpG x -> [(Pat, ExpG t)] -> ExpG t
63caseE v alt = do
65caseE v alt = do
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)
66 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') (BDecls [])) a) alt
70 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') (BDecls [])) a) alt
68 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedAlt $ runExpression a') (BDecls [])) a) alt
72 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedAlt $ runExpression a') (BDecls [])) a) alt
70 return $ Expression $ Case (runExpression v') alt'
74 return $ Expression $ Case (runExpression v') alt'
@@ -210,7 +214,7 @@ instance GenExp (FunRef t) where
211-- | Generate a ExportSpec for a given function item.
215-- | Generate a ExportSpec for a given function item.
212exportFun :: FunRef t -> ExportSpec
216exportFun :: 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)
214exportFun (FunRef name) = EVar NoNamespace (UnQual name)
218exportFun (FunRef name) = EVar NoNamespace (UnQual name)
216exportFun (FunRef name) = EVar (UnQual name)
220exportFun (FunRef name) = EVar (UnQual name)
@@ -220,7 +224,11 @@ exportFun (FunRef name) = EVar (UnQual name)
220addDecl :: Name -> ExpG t -> ModuleM (FunRef t)
224addDecl :: Name -> ExpG t -> ModuleM (FunRef t)
221addDecl name e = ModuleM $ do
225addDecl name e = ModuleM $ do
222 let (body, mods) = runGenerate e
226 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]])
223 tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) $ BDecls []]])
230 tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) $ BDecls []]])
224 return $ FunRef name
232 return $ FunRef name
226-- | Extract the Module from a module generator.
234-- | Extract the Module from a module generator.