1module Libraries (libraries, addPrelude, prelude) where
4import qualified Data.Map as Map
5import Data.List (inits)
7import LoadLibraries (docs)
10addPrelude (Module name exs ims stmts) = Module name exs (customIms ++ ims) stmts
11 where customIms = concatMap addModule prelude
13 addModule (n, method) = case lookup n ims of
14 Nothing -> [(n, method)]
17prelude = text : map (\n -> (n, Hiding [])) modules
19 text = ("Graphics.Text", Hiding ["link", "color", "height"])
20 modules = [ "Prelude", "Signal", "List", "Maybe", "Time"
21 , "Graphics.Element", "Graphics.Color"
22 , "Graphics.Collage", "Graphics.Geometry" ]
24libraries :: Map.Map String (Map.Map String String)
25libraries = case getLibs of
26 Error err -> error err
27 Ok libs -> Map.unionWith Map.union libs nilAndTuples
28 where nilAndTuples = Map.singleton "Prelude" (Map.fromList pairs)
29 pairs = ("Nil", "List a") : map makeTuple (inits ['a'..'i'])
31 let name = "Tuple" ++ show (length cs)
32 in (name, concatMap (\c -> c : " -> ") cs ++
33 name ++ concatMap (\c -> [' ',c]) cs)
35getLibs :: Result (Map.Map String (Map.Map String String))
37 obj <- decodeStrict docs :: Result (JSObject JSValue)
38 modules <- valFromObj "modules" obj :: Result [JSObject JSValue]
39 Map.fromList `fmap` mapM getValues modules
42getName :: JSObject JSValue -> Result String
43getName obj = valFromObj "name" obj
45getType :: JSObject JSValue -> Result String
46getType obj = valFromObj "type" obj
48getValue :: JSObject JSValue -> Result (String,String)
49getValue obj = do n <- getName obj
53getValues :: JSObject JSValue -> Result (String, Map.Map String String)
56 vs <- valFromObj "values" obj
57 vals <- mapM getValue vs
58 return (name, Map.fromList vals)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list