1module Libraries (libraries, addPrelude) where
4import qualified Data.Map as Map
5import Data.List (inits)
7import LoadLibraries (docs)
11addPrelude :: Module -> Module
12addPrelude (Module name exs ims stmts) =
14 mapM print $ customIms ++ ims
15 return $ Module name exs (customIms ++ ims) stmts
16 where customIms = concatMap addModule prelude
18 addModule (n, method) = case lookup n ims of
19 Nothing -> [(n, method)]
20 Just (As m) -> [(n, method)]
23prelude = text : map (\n -> (n, Hiding [])) modules
25 text = ("Graphics.Text", Hiding ["link", "color", "height"])
26 modules = [ "Prelude", "Signal", "List", "Maybe", "Time"
27 , "Graphics.Element", "Graphics.Color"
28 , "Graphics.Collage", "Graphics.Geometry" ]
30libraries :: Map.Map String (Map.Map String String)
33 Error err -> error err
34 Ok libs -> Map.unionWith Map.union libs nilAndTuples
35 where nilAndTuples = Map.singleton "Prelude" (Map.fromList pairs)
37 [ ("Cons", "a -> [a] -> [a]")
39 ] ++ map makeTuple (inits ['a'..'i'])
42 let name = "Tuple" ++ show (length cs)
43 in (name, concatMap (\c -> c : " -> ") cs ++
44 name ++ concatMap (\c -> [' ',c]) cs)
46getLibs :: Result (Map.Map String (Map.Map String String))
48 obj <- decodeStrict docs :: Result (JSObject JSValue)
49 modules <- valFromObj "modules" obj :: Result [JSObject JSValue]
50 Map.fromList `fmap` mapM getValues modules
53getName :: JSObject JSValue -> Result String
54getName obj = valFromObj "name" obj
56getType :: JSObject JSValue -> Result String
57getType obj = valFromObj "type" obj
59getValue :: JSObject JSValue -> Result (String,String)
60getValue obj = do n <- getName obj
64getValues :: JSObject JSValue -> Result (String, Map.Map String String)
67 vs <- valFromObj "values" obj
68 vals <- mapM getValue vs
69 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