-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Disciplined Disciple Compiler common utilities.
--
-- This package re-exports the main external dependencies of the
-- Disciplined Disciple Compiler project, and provides some common
-- utilities.
@package ddc-base
@version 0.3.2.1
-- | Replacements for unhelpful Haskell list functions. If the standard
-- versions are passed an empty list then we don't get a proper source
-- location.
module DDC.Data.ListUtils
-- | Take the head of a list, or Nothing if it's empty.
takeHead :: [a] -> Maybe a
-- | Take the tail of a list, or Nothing if it's empty.
takeTail :: [a] -> Maybe [a]
-- | Take the init of a list, or Nothing if it's empty.
takeInit :: [a] -> Maybe [a]
-- | Retrieve the element at the given index, or `Nothing if it's not
-- there.
index :: [a] -> Int -> Maybe a
module DDC.Data.Canned
-- | This function has a show instance that prints "CANNED" for any
-- contained type. We use it to wrap functional fields in data types that
-- we still want to derive Show instances for.
data Canned a
Canned :: a -> Canned a
instance Show (Canned a)
-- | A simple exception monad.
module DDC.Control.Monad.Check
data CheckM err a
CheckM :: (Either err a) -> CheckM err a
-- | Throw a type error in the monad.
throw :: err -> CheckM err a
-- | Take the result from a check monad.
result :: CheckM err a -> Either err a
instance Monad (CheckM err)
-- | Pretty printer utilities.
--
-- This is a re-export of Daan Leijen's pretty printer package
-- (wl-pprint), but with a Pretty class that includes a
-- pprPrec function.
module DDC.Base.Pretty
class Pretty a where ppr = pprPrec 0 pprPrec _ = ppr
ppr :: Pretty a => a -> Doc
pprPrec :: Pretty a => Int -> a -> Doc
-- | Wrap a Doc in parens if the predicate is true.
pprParen :: Bool -> Doc -> Doc
-- | How to pretty print a doc.
data RenderMode
-- | Render the doc with indenting.
RenderPlain :: RenderMode
-- | Render the doc without indenting.
RenderIndent :: RenderMode
-- | Render a doc with the given mode.
render :: RenderMode -> Doc -> String
-- | Convert a Doc to a string without indentation.
renderPlain :: Doc -> String
-- | Convert a Doc to a string with indentation
renderIndent :: Doc -> String
-- | Put a Doc to stdout using the given mode.
putDoc :: RenderMode -> Doc -> IO ()
-- | Put a Doc to stdout using the given mode.
putDocLn :: RenderMode -> Doc -> IO ()
instance Eq RenderMode
instance Show RenderMode
instance (Pretty a, Pretty b) => Pretty (a, b)
instance Pretty a => Pretty (Set a)
instance Pretty a => Pretty [a]
instance Pretty Char
instance Pretty Integer
instance Pretty Int
instance Pretty Bool
instance Pretty ()
module DDC.Data.SourcePos
-- | A position in a source file.
--
-- If there is no file path then we assume that the input has been read
-- from an interactive session and display ''<interactive>'' when
-- pretty printing.
data SourcePos
SourcePos :: String -> Int -> Int -> SourcePos
sourcePosSource :: SourcePos -> String
sourcePosLine :: SourcePos -> Int
sourcePosColumn :: SourcePos -> Int
instance Eq SourcePos
instance Show SourcePos
instance Pretty SourcePos
instance NFData SourcePos
module DDC.Data.Token
-- | Wrapper for primitive token type that gives it a source position.
data Token t
Token :: t -> SourcePos -> Token t
tokenTok :: Token t -> t
tokenSourcePos :: Token t -> SourcePos
-- | Take the parsec style source position from a token.
takeParsecSourcePos :: Token k -> SourcePos
-- | Take the line number of a token.
tokenLine :: Token t -> Int
-- | Take the column number of a token.
tokenColumn :: Token t -> Int
instance Eq t => Eq (Token t)
instance Show t => Show (Token t)
-- | Parser utilities.
module DDC.Base.Parser
-- | A generic parser, parameterised over token and return types.
type Parser k a = Eq k => ParsecT [Token k] (ParserState k) Identity a
-- | A parser state that keeps track of the name of the source file.
data ParserState k
ParseState :: (k -> String) -> String -> ParserState k
stateTokenShow :: ParserState k -> k -> String
stateFileName :: ParserState k -> String
-- | A position in a source file.
--
-- If there is no file path then we assume that the input has been read
-- from an interactive session and display ''<interactive>'' when
-- pretty printing.
data SourcePos
-- | Run a generic parser.
runTokenParser :: Eq k => (k -> String) -> String -> Parser k a -> [Token k] -> Either ParseError a
-- | Accept a token if the function returns Just.
pTokMaybe :: (k -> Maybe a) -> Parser k a
-- | Accept a token if the function return Just, also returning the
-- source position of that token.
pTokMaybeSP :: (k -> Maybe a) -> Parser k (a, SourcePos)
-- | Accept a token and return the given value.
pTokAs :: Eq k => k -> t -> Parser k t
-- | Accept a token and return the given value, along with the source
-- position of the token.
pTokAsSP :: Eq k => k -> t -> Parser k (t, SourcePos)
-- | Accept the given token.
pTok :: Eq k => k -> Parser k ()
-- | Accept the given token, returning its source position.
pTokSP :: Eq k => k -> Parser k SourcePos
instance Pretty Message
instance Pretty ParseError