@@ -3,7 +3,6 @@
33{-# LANGUAGE ScopedTypeVariables #-}
44{-# LANGUAGE UndecidableInstances #-}
55{-# LANGUAGE FlexibleInstances #-}
6−{-# LANGUAGE CPP #-}
76module Language.Haskell.Generate.Monad
87 ( Generate(..), ExpG
98 , runGenerate, newName
@@ -36,8 +35,6 @@ import Language.Haskell.Exts.SrcLoc
3635import Language.Haskell.Exts.Syntax
3736import Language.Haskell.Generate.Expression
3837
39−import Prelude
40−
4138--------------------------------------------------------------------------------
4239-- Generate expressions
4340
@@ -64,13 +61,7 @@ generateExp = prettyPrint . runExpression . fst . runGenerate
6461caseE :: ExpG x -> [(Pat, ExpG t)] -> ExpG t
6562caseE v alt = do
6663 v' <- v
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)
70− alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') (BDecls [])) a) alt
71−#else
7264 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedAlt $ runExpression a') (BDecls [])) a) alt
73−#endif
7465 return $ Expression $ Case (runExpression v') alt'
7566
7667-- | Import a function from a module. This function is polymorphic in the type of the resulting expression,
@@ -214,31 +205,19 @@ instance GenExp (FunRef t) where
214205
215206-- | Generate a ExportSpec for a given function item.
216207exportFun :: FunRef t -> ExportSpec
217−#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0)
218−exportFun (FunRef name) = EVar NoNamespace (UnQual name)
219−#else
220208exportFun (FunRef name) = EVar (UnQual name)
221−#endif
222209
223210-- | Add a declaration to the module. Return a reference to it that can be used to either apply the function to some values or export it.
224211addDecl :: Name -> ExpG t -> ModuleM (FunRef t)
225212addDecl name e = ModuleM $ do
226213 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
230214 tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) $ BDecls []]])
231−#endif
232215 return $ FunRef name
233216
234217-- | Extract the Module from a module generator.
235218runModuleM :: ModuleG -> String -> Module
236219runModuleM (ModuleM act) name =
237−#if MIN_VERSION_haskell_src_exts(1,16,0)
238− Module noLoc (ModuleName name) [] Nothing export (map (\md -> ImportDecl noLoc md True False False Nothing Nothing Nothing) $ S.toList imps) decls
239−#else
240220 Module noLoc (ModuleName name) [] Nothing export (map (\md -> ImportDecl noLoc md True False Nothing Nothing Nothing) $ S.toList imps) decls
241−#endif
242221 where (export, (imps, decls)) = runWriter act
243222
244223-- | Generate the source code for a module.