@@ -1,39 +1,6 @@
11module Language.Haskell.Generate
2− ( -- $intro
3− module X
2+ ( module X
43 ) where
54
65import Language.Haskell.Generate.Base as X
76import Language.Haskell.Generate.PreludeDef as X
8−
9−{- $intro
10− This library allows you to generate type-correct haskell expressions. To use it, you need to import this module:
11−
12−> import Language.Haskell.Generate
13−
14− This will import the methods for generating haskell expressions and also a list of predefined expressions consisting of functions from the haskell Prelude
15− that you can use to build your own expressions. For example, here is an expression that reads the file 'names':
16−
17−> readNames :: ExpG (IO String)
18−> readNames = readFile' <>$ expr "names"
19−
20− First, look at the type of readNames. @'ExpG'@ is a data type provided by haskell-generate for haskell expressions. We want to generate an expression
21− that returns an IO String, so the type of readNames is @ExpG (IO String)@.
22− @readFile'@ is an expression for the haskell readFile function. You can use almost any Prelude function in your expression by adding an apostrophe to
23− the end of the function name.
24− We use (<>$) to generate a expression that applies 'readFile' to the expression "names". @'expr'@ automagically generates a literal expression.
25−
26− Now that we have an expression to read the @names@ file, we can generate a module with it:
27−
28−> myModule :: ModuleG
29−> myModule = do
30−> readNamesDecl <- addDecl (Ident "readNames") readNames
31−> return $ Just [exportFun readNamesDecl]
32−
33−
34−
35−> main :: IO ()
36−> main = do
37−> putStrLn $ generateModule myModule "FooBar"
38−
39−-}