1
module Mueval.Context (
9
-----------------------------------------------------------------------------
11
-- | Return false if any of the listed modules cannot be found in the whitelist.
12
cleanModules :: [String] -> Bool
13
cleanModules = all (`elem` defaultModules)
15
{- | Modules which we should load by default. These are of course whitelisted.
16
Specifically, we want the Prelude because otherwise things are horribly
17
crippled; we want SimpleReflect so we can do neat things (for said neat
19
<http://twan.home.fmf.nl/blog/haskell/simple-reflection-of-expressions.details>);
20
and we want ShowQ and ShowFun to neuter IO stuff even more.
21
The rest should be safe to import without clashes, according to the Lambdabot
23
defaultModules :: [String]
24
defaultModules = ["Prelude",
27
"Debug.SimpleReflect",
29
"Control.Applicative",
33
"Control.Monad.Error",
35
"Control.Monad.Identity",
36
"Control.Monad.Instances",
38
"Control.Monad.Reader",
39
"Control.Monad.State",
40
"Control.Monad.State",
41
"Control.Monad.Writer",
57
{- -- Commented out because they are not necessarily available. If anyone misses
58
-- them, perhaps we could look into forcing a dependency on them in the Cabal
59
-- file or perhaps enable them via a CLI flag. For now, we'll stash them in a comment.
61
"Control.Parallel.Strategies",
62
"Data.Number.BigFloat",
66
"Data.Number.Interval",
67
"Data.Number.Natural",
68
"Data.Number.Symbolic",
79
"Text.PrettyPrint.HughesPJ",
82
defaultPackages :: [String]
83
defaultPackages = [ "array"
89
{- | Borrowed from Lambdabot, this is the whitelist of modules which should be
90
safe to import functions from, but which we don't want to import by
92
FIXME: make these qualified imports. The GHC API & Hint currently do not
93
support qualified imports.
94
WARNING: You can import these with --module, certainly, but the onus is on
95
the user to make sure they fully disambiguate function names; ie:
97
> mueval --module Data.Map -e "Prelude.map (+1) [1..100]"
99
qualifiedModules :: [(String, Maybe String)]
101
-- ("Control.Arrow.Transformer", Just "AT"),
102
-- ("Control.Arrow.Transformer.All", Just "AT"),
103
("Data.ByteString", Just "BS"),
104
("Data.ByteString.Char8", Just "BSC"),
105
("Data.ByteString.Lazy", Just "BSL"),
106
("Data.ByteString.Lazy.Char8", Just "BSLC"),
107
("Data.Foldable", Just "Data.Foldable"),
108
-- ("Data.Generics", Just "Data.Generics"),
109
("Data.IntMap", Just "IM"),
110
("Data.IntSet", Just "IS"),
111
("Data.Map", Just "M"),
112
("Data.Sequence", Just "Data.Sequence"),
113
("Data.Set", Just "S"),
114
("Data.Traversable", Just "Data.Traversable") ]