1module Libraries (libraries, addPrelude) where
4import qualified Data.Map as Map
5import Data.List (inits)
7import LoadLibraries (docs)
9addPrelude :: Module -> Module
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)]
15 Just (As m) -> [(n, method)]
18prelude = text : map (\n -> (n, Hiding [])) modules
20 text = ("Graphics.Text", Hiding ["link", "color", "height"])
21 modules = [ "Prelude", "Signal", "List", "Maybe", "Time"
22 , "Graphics.Element", "Graphics.Color"
23 , "Graphics.Collage", "Graphics.Geometry" ]
25libraries :: Map.Map String (Map.Map String String)
28 Error err -> error err
29 Ok libs -> Map.unionWith Map.union libs nilAndTuples
30 where nilAndTuples = Map.singleton "Prelude" (Map.fromList pairs)
32 [ ("Cons", "a -> [a] -> [a]")
34 ] ++ map makeTuple (inits ['a'..'i'])
37 let name = "Tuple" ++ show (length cs)
38 in (name, concatMap (\c -> c : " -> ") cs ++
39 name ++ concatMap (\c -> [' ',c]) cs)
41getLibs :: Result (Map.Map String (Map.Map String String))
43 obj <- decodeStrict docs :: Result (JSObject JSValue)
44 modules <- valFromObj "modules" obj :: Result [JSObject JSValue]
45 Map.fromList `fmap` mapM getValues modules
48getName :: JSObject JSValue -> Result String
49getName obj = valFromObj "name" obj
51getType :: JSObject JSValue -> Result String
52getType obj = valFromObj "type" obj
54getValue :: JSObject JSValue -> Result (String,String)
55getValue obj = do n <- getName obj
59getValues :: JSObject JSValue -> Result (String, Map.Map String String)
62 vs <- valFromObj "values" obj
63 vals <- mapM getValue vs
64 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