~ubuntu-branches/ubuntu/vivid/haskell-mueval/vivid

« back to all changes in this revision

Viewing changes to Mueval/Context.hs

  • Committer: Package Import Robot
  • Author(s): Joachim Breitner
  • Date: 2013-06-24 16:36:00 UTC
  • Revision ID: package-import@ubuntu.com-20130624163600-dl1f4j7mch20xfgk
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module Mueval.Context (
 
2
  cleanModules,
 
3
  defaultModules,
 
4
  defaultPackages,
 
5
  qualifiedModules,
 
6
) where
 
7
 
 
8
 
 
9
-----------------------------------------------------------------------------
 
10
 
 
11
-- | Return false if any of the listed modules cannot be found in the whitelist.
 
12
cleanModules :: [String] -> Bool
 
13
cleanModules = all (`elem` defaultModules)
 
14
 
 
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
 
18
   things, see
 
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
 
22
   sources. -}
 
23
defaultModules :: [String]
 
24
defaultModules = ["Prelude",
 
25
                  "ShowQ",
 
26
                  "ShowFun",
 
27
                  "Debug.SimpleReflect",
 
28
                  "Data.Function",
 
29
                  "Control.Applicative",
 
30
                  "Control.Arrow",
 
31
                  "Control.Monad",
 
32
                  "Control.Monad.Cont",
 
33
                  "Control.Monad.Error",
 
34
                  "Control.Monad.Fix",
 
35
                  "Control.Monad.Identity",
 
36
                  "Control.Monad.Instances",
 
37
                  "Control.Monad.RWS",
 
38
                  "Control.Monad.Reader",
 
39
                  "Control.Monad.State",
 
40
                  "Control.Monad.State",
 
41
                  "Control.Monad.Writer",
 
42
                  "Data.Array",
 
43
                  "Data.Bits",
 
44
                  "Data.Bool",
 
45
                  "Data.Char",
 
46
                  "Data.Complex",
 
47
                  "Data.Dynamic",
 
48
                  "Data.Either",
 
49
                  "Data.Eq",
 
50
                  "Data.Fixed",
 
51
                  "Data.Graph",
 
52
                  "Data.Int",
 
53
                  "Data.Ix",
 
54
                  "Data.List",
 
55
                  "Data.Maybe",
 
56
                  "Data.Monoid",
 
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.
 
60
               "Control.Parallel",
 
61
               "Control.Parallel.Strategies",
 
62
               "Data.Number.BigFloat",
 
63
               "Data.Number.CReal",
 
64
               "Data.Number.Dif",
 
65
               "Data.Number.Fixed",
 
66
               "Data.Number.Interval",
 
67
               "Data.Number.Natural",
 
68
               "Data.Number.Symbolic",
 
69
               "Math.OEIS",
 
70
-}
 
71
               "Data.Ord",
 
72
               "Data.Ratio",
 
73
               "Data.Tree",
 
74
               "Data.Tuple",
 
75
               "Data.Typeable",
 
76
               "Data.Word",
 
77
               "System.Random",
 
78
               "Test.QuickCheck",
 
79
               "Text.PrettyPrint.HughesPJ",
 
80
               "Text.Printf"]
 
81
 
 
82
defaultPackages :: [String]
 
83
defaultPackages = [ "array"
 
84
                  , "base"
 
85
                  , "bytestring"
 
86
                  , "containers"
 
87
                  ]
 
88
 
 
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
 
91
   default.
 
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:
 
96
 
 
97
   > mueval  --module Data.Map -e "Prelude.map (+1) [1..100]"
 
98
-}
 
99
qualifiedModules :: [(String, Maybe String)]
 
100
qualifiedModules = [
 
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") ]