Safe Haskell | None |
---|---|
Language | Haskell2010 |
- Supporting infrastructure and system utilities
- class HasSourcePath a where
- data Location
- data L a = L Location a
- unLoc :: L a -> a
- noLoc :: a -> L a
- ppLocation :: FilePath -> Location -> Doc
- ppL :: (Pretty a1, Pretty a) => L a1 -> a -> Doc
- data Options
- data Flags = Flags {
- optMode :: Mode
- optStopAfterPhase :: Phase
- optVerbosity :: Verbosity
- optShowCPUTime :: Bool
- optOutputFormats :: [OutputFormat]
- optSISR :: Maybe SISRFormat
- optHaskellOptions :: Set HaskellOption
- optLexicalCats :: Set String
- optLiteralCats :: Set Ident
- optGFODir :: Maybe FilePath
- optOutputDir :: Maybe FilePath
- optGFLibPath :: Maybe [FilePath]
- optDocumentRoot :: Maybe FilePath
- optRecomp :: Recomp
- optProbsFile :: Maybe FilePath
- optRetainResource :: Bool
- optName :: Maybe String
- optPreprocessors :: [String]
- optEncoding :: Maybe String
- optPMCFG :: Bool
- optOptimizations :: Set Optimization
- optOptimizePGF :: Bool
- optSplitPGF :: Bool
- optCFGTransforms :: Set CFGTransform
- optLibraryPath :: [FilePath]
- optStartCat :: Maybe String
- optSpeechLanguage :: Maybe String
- optLexer :: Maybe String
- optUnlexer :: Maybe String
- optWarnings :: [Warning]
- optDump :: [Dump]
- optTagsOnly :: Bool
- optHeuristicFactor :: Maybe Double
- optCaseSensitive :: Bool
- optPlusAsBind :: Bool
- optJobs :: Maybe (Maybe Int)
- optTrace :: Bool
- data Mode
- data Phase
- data Verbosity
- data OutputFormat
- data SISRFormat
- data Optimization
- data CFGTransform
- data HaskellOption
- newtype Dump = Dump Pass
- data Pass
- data Recomp
- outputFormatsExpl :: [((String, OutputFormat), String)]
- parseOptions :: ErrorMonad err => [String] -> err (Options, [FilePath])
- parseModuleOptions :: ErrorMonad err => [String] -> err Options
- fixRelativeLibPaths :: [Char] -> [[Char]] -> Options -> Options
- optionsGFO :: Options -> [(String, Literal)]
- optionsPGF :: Options -> [(String, Literal)]
- addOptions :: Options -> Options -> Options
- concatOptions :: [Options] -> Options
- noOptions :: Options
- modifyFlags :: (Flags -> Flags) -> Options
- helpMessage :: String
- flag :: (Flags -> a) -> Options -> a
- cfgTransform :: Options -> CFGTransform -> Bool
- haskellOption :: Options -> HaskellOption -> Bool
- readOutputFormat :: Monad m => String -> m OutputFormat
- isLexicalCat :: Options -> String -> Bool
- isLiteralCat :: Options -> Ident -> Bool
- renameEncoding :: String -> String
- getEncoding :: Options -> String
- defaultEncoding :: [Char]
- setOptimization :: Optimization -> Bool -> Options
- setCFGTransform :: CFGTransform -> Bool -> Options
- verbAtLeast :: Options -> Verbosity -> Bool
- dump :: Options -> Dump -> Bool
- data Err a
- err :: (String -> b) -> (a -> b) -> Err a -> b
- maybeErr :: ErrorMonad m => String -> Maybe a -> m a
- testErr :: ErrorMonad m => Bool -> String -> m ()
- fromErr :: a -> Err a -> a
- errIn :: ErrorMonad m => String -> m a -> m a
- lookupErr :: (ErrorMonad m, Eq a, Show a) => a -> [(a, b)] -> m b
- class (Functor m, Monad m) => ErrorMonad m where
- checks :: ErrorMonad m => [m a] -> m a
- liftErr :: ErrorMonad m => Err a -> m a
- checkUnique :: (Show a, Eq a) => [a] -> [String]
- unifyMaybeBy :: (Eq b, Monad m) => (a -> b) -> Maybe a -> Maybe a -> m (Maybe a)
- unifyMaybe :: (Eq a, Monad m) => Maybe a -> Maybe a -> m (Maybe a)
- mapPairListM :: Monad m => ((a, b) -> m c) -> [(a, b)] -> m [(a, c)]
- mapPairsM :: Monad m => (b -> m c) -> [(a, b)] -> m [(a, c)]
- pairM :: Monad m => (b -> m c) -> (b, b) -> m (c, c)
- type BinTree a b = Map a b
- emptyBinTree :: BinTree a b
- isInBinTree :: Ord a => a -> BinTree a b -> Bool
- lookupTree :: (ErrorMonad m, Ord a) => (a -> String) -> a -> BinTree a b -> m b
- lookupTreeManyAll :: Ord a => (a -> String) -> [BinTree a b] -> a -> [b]
- updateTree :: Ord a => (a, b) -> BinTree a b -> BinTree a b
- buildTree :: Ord a => [(a, b)] -> BinTree a b
- filterBinTree :: Ord a => (a -> b -> Bool) -> BinTree a b -> BinTree a b
- mapTree :: ((a, b) -> c) -> BinTree a b -> BinTree a c
- tree2list :: BinTree a b -> [(a, b)]
- indent :: Int -> String -> String
- (+++) :: String -> String -> String
- (++-) :: String -> String -> String
- (++++) :: String -> String -> String
- (+++-) :: String -> String -> String
- (+++++) :: String -> String -> String
- prUpper :: String -> String
- prReplicate :: Int -> String -> String
- prTList :: String -> [String] -> String
- prQuotedString :: String -> String
- prParenth :: String -> String
- prCurly :: String -> String
- prBracket :: String -> String
- prArgList :: [String] -> String
- prSemicList :: [String] -> String
- prCurlyList :: [String] -> String
- restoreEscapes :: String -> String
- numberedParagraphs :: [[String]] -> [String]
- prConjList :: String -> [String] -> String
- prIfEmpty :: String -> String -> String -> String -> String
- wrapLines :: Int -> String -> String
- topoTest :: Ord a => [(a, [a])] -> Either [a] [[a]]
- topoTest2 :: Ord a => [(a, [a])] -> Either [[a]] [[a]]
- ifNull :: b -> ([a] -> b) -> [a] -> b
- combinations :: [[a]] -> [[a]]
- done :: Monad m => m ()
- readIntArg :: String -> Int
- iterFix :: Eq a => ([a] -> [a]) -> [a] -> [a]
- chunks :: Eq a => a -> [a] -> [[a]]
- putIfVerb :: Output f => Options -> String -> f ()
- type FileName = String
- type InitPath = String
- type FullPath = String
- gfLibraryPath :: [Char]
- gfGrammarPathVar :: [Char]
- getLibraryDirectory :: MonadIO io => Options -> io [FilePath]
- getGrammarPath :: MonadIO io => [FilePath] -> io [FilePath]
- extendPathEnv :: MonadIO io => Options -> io [FilePath]
- getSubdirs :: FilePath -> IO [FilePath]
- justModuleName :: FilePath -> String
- isGF :: FilePath -> Bool
- isGFO :: FilePath -> Bool
- gfFile :: FilePath -> FilePath
- gfoFile :: FilePath -> FilePath
- gf2gfo :: Options -> FilePath -> FilePath
- gf2gfo' :: Maybe FilePath -> FilePath -> FilePath
- splitInModuleSearchPath :: String -> [FilePath]
- type IOE a = IO a
- tryIOE :: IOE a -> IO (Err a)
- useIOE :: a -> IOE a -> IO a
- maybeIO :: MonadIO f => IO a -> f (Maybe a)
- die :: String -> IO a
- class Monad m => Output m where
- putPointE :: (MonadIO m, Output m) => Verbosity -> Options -> String -> m b -> m b
- ioErrorText :: IOError -> String
- timeIt :: MonadIO m => m t -> m (Integer, t)
- writeUTF8File :: FilePath -> String -> IO ()
- readBinaryFile :: FilePath -> IO String
- writeBinaryFile :: FilePath -> String -> IO ()
- class Monad m => MonadIO m where
- liftErr :: ErrorMonad m => Err a -> m a
- catch :: IO a -> (IOError -> IO a) -> IO a
- try :: IO a -> IO (Either IOError a)
- setConsoleEncoding :: IO ()
- changeConsoleEncoding :: String -> IO ()
- data TermColors = TermColors {}
- getTermColors :: MonadIO m => m TermColors
- class Binary t
- encode :: Binary a => a -> ByteString
- decode :: Binary a => ByteString -> a
- encodeFile :: Binary a => FilePath -> a -> IO ()
- decodeFile :: Binary a => FilePath -> IO a
Supporting infrastructure and system utilities
Source locations
class HasSourcePath a where Source #
sourcePath :: a -> FilePath Source #
Attaching location information
Command line options
Option types
data OutputFormat Source #
data SISRFormat Source #
SISR_WD20030401 | SISR Working draft 1 April 2003 http://www.w3.org/TR/2003/WD-semantic-interpretation-20030401/ |
SISR_1_0 |
data Optimization Source #
data CFGTransform Source #
data HaskellOption Source #
outputFormatsExpl :: [((String, OutputFormat), String)] Source #
Option parsing
:: ErrorMonad err | |
=> [String] | list of string arguments |
-> err (Options, [FilePath]) |
:: ErrorMonad err | |
=> [String] | list of string arguments |
-> err Options |
Option pretty-printing
optionsGFO :: Options -> [(String, Literal)] Source #
Pretty-print the options that are preserved in .gfo files.
optionsPGF :: Options -> [(String, Literal)] Source #
Pretty-print the options that are preserved in .pgf files.
Option manipulation
concatOptions :: [Options] -> Options Source #
helpMessage :: String Source #
Checking specific options
cfgTransform :: Options -> CFGTransform -> Bool Source #
haskellOption :: Options -> HaskellOption -> Bool Source #
readOutputFormat :: Monad m => String -> m OutputFormat Source #
renameEncoding :: String -> String Source #
This is for bacward compatibility. Since GHC 6.12 we started using the native Unicode support in GHC but it uses different names for the code pages.
getEncoding :: Options -> String Source #
defaultEncoding :: [Char] Source #
Setting specific options
setOptimization :: Optimization -> Bool -> Options Source #
setCFGTransform :: CFGTransform -> Bool -> Options Source #
Convenience methods for checking options
The Error monad
Like Maybe
type with error msgs
errIn :: ErrorMonad m => String -> m a -> m a Source #
Error monad class
class (Functor m, Monad m) => ErrorMonad m where Source #
checks :: ErrorMonad m => [m a] -> m a Source #
liftErr :: ErrorMonad m => Err a -> m a Source #
Checking
unifyMaybe :: (Eq a, Monad m) => Maybe a -> Maybe a -> m (Maybe a) Source #
this is what happens when matching two values in the same module
Monadic operations on lists and pairs
mapPairListM :: Monad m => ((a, b) -> m c) -> [(a, b)] -> m [(a, c)] Source #
Binary search trees; now with FiniteMap
emptyBinTree :: BinTree a b Source #
lookupTree :: (ErrorMonad m, Ord a) => (a -> String) -> a -> BinTree a b -> m b Source #
Printing
prQuotedString :: String -> String Source #
prSemicList :: [String] -> String Source #
prCurlyList :: [String] -> String Source #
restoreEscapes :: String -> String Source #
numberedParagraphs :: [[String]] -> [String] Source #
Topological sorting
topoTest :: Ord a => [(a, [a])] -> Either [a] [[a]] Source #
Topological sorting with test of cyclicity
topoTest2 :: Ord a => [(a, [a])] -> Either [[a]] [[a]] Source #
Topological sorting with test of cyclicity, new version /TH 2012-06-26
Misc
combinations :: [[a]] -> [[a]] Source #
combinations
is the same as sequence
!!!
peb 30/5-04
readIntArg :: String -> Int Source #
iterFix :: Eq a => ([a] -> [a]) -> [a] -> [a] Source #
Fix point iterator (for computing e.g. transitive closures or reachability)
Files and IO
GF files path and library path manipulation
gfLibraryPath :: [Char] Source #
gfGrammarPathVar :: [Char] Source #
extendPathEnv :: MonadIO io => Options -> io [FilePath] Source #
extends the search path with the
gfLibraryPath
and gfGrammarPathVar
environment variables. Returns only existing paths.
justModuleName :: FilePath -> String Source #
splitInModuleSearchPath :: String -> [FilePath] Source #
Error handling in the IO monad
useIOE :: a -> IOE a -> IO a Source #
Print the error message and return a default value if the IO operation fail
s
Diagnostic output
ioErrorText :: IOError -> String Source #
Because GHC adds the confusing text "user error" for failures caused by
calls to fail
.
Timing
File IO
Reused
class Monad m => MonadIO m where #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
MonadIO IO | |
MonadIO m => MonadIO (CGIT m) | |
MonadIO m => MonadIO (MaybeT m) | |
MonadIO m => MonadIO (InputT m) | |
MonadIO m => MonadIO (ListT m) | |
MonadIO m => MonadIO (ExceptT e m) | |
(Error e, MonadIO m) => MonadIO (ErrorT e m) | |
MonadIO m => MonadIO (StateT s m) | |
MonadIO m => MonadIO (StateT s m) | |
(Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
(Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
MonadIO m => MonadIO (IdentityT * m) | |
MonadIO m => MonadIO (ReaderT * r m) | |
MonadIO m => MonadIO (ContT * r m) | |
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
liftErr :: ErrorMonad m => Err a -> m a Source #
Backwards compatible try and catch
Console IO
Changing which character encoding to use for console IO
setConsoleEncoding :: IO () Source #
Set the console encoding (for Windows, has no effect on Unix-like systems)
changeConsoleEncoding :: String -> IO () Source #
Console colors
getTermColors :: MonadIO m => m TermColors Source #
Binary serialisation
The Binary
class provides put
and get
, methods to encode and
decode a Haskell value to a lazy ByteString. It mirrors the Read and
Show classes for textual representation of Haskell types, and is
suitable for serialising Haskell values to disk, over the network.
For parsing and generating simple external binary formats (e.g. C structures), Binary may be used, but in general is not suitable for complex protocols. Instead use the Put and Get primitives directly.
Instances of Binary should satisfy the following property:
decode . encode == id
That is, the get
and put
methods should be the inverse of each
other. A range of instances are provided for basic Haskell types.
put, get
encode :: Binary a => a -> ByteString Source #
Encode a value using binary serialisation to a lazy ByteString.
decode :: Binary a => ByteString -> a Source #
Decode a value from a lazy ByteString, reconstructing the original structure.
encodeFile :: Binary a => FilePath -> a -> IO () Source #
Lazily serialise a value to a file
This is just a convenience function, it's defined simply as:
encodeFile f = B.writeFile f . encode
So for example if you wanted to compress as well, you could use:
B.writeFile f . compress . encode
decodeFile :: Binary a => FilePath -> IO a Source #
Lazily reconstruct a value previously written to a file.
This is just a convenience function, it's defined simply as:
decodeFile f = return . decode =<< B.readFile f
So for example if you wanted to decompress as well, you could use:
return . decode . decompress =<< B.readFile f