1module LoadLibraries (docs) where
3import Control.DeepSeq (force)
4import qualified Control.Exception as E
8import System.IO.Unsafe (unsafePerformIO)
10-- See stackoverflow discussion for trade-off between using unsafeIO or TemplateHaskell:
11-- http://stackoverflow.com/questions/12716215/load-pure-global-variable-from-file
13-- Given the awkwardness of including a compile-time generated file
14-- vs loading static data, then the unsafeIO seems better.
18docs = force . unsafePerformIO . safeReadDocs . getDataFileName $ "docs.json"
20safeReadDocs :: IO FilePath -> IO String
21safeReadDocs path = E.catch (readDocs path) (emitError path)
23readDocs :: IO FilePath -> IO String
26 exists <- doesFileExist name
27 if exists then readFile name
28 else ioError . userError $ "File Not Found"
31emitError :: IO FilePath -> IOError -> IO String
32emitError path err = do
34 putStrLn $ "Error! Types for standard library not loaded properly!\n File should be here:" ++ name ++ "\n The file is created and copied by command: cabal install"
36 return "{\"modules\":[]}"
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