-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Functional sed for JSON
--   
--   jl ("JSON lambda") is a tiny functional language for querying and
--   manipulating JSON.
@package jl
@version 0.1.0

module JL.Types
data ParseException
TokenizerError :: !ParseError -> ParseException
ParserError :: !ParseError -> ParseException

-- | A type.
data Type
VariableType :: !TypeVariable -> Type
FunctionType :: !Type -> !Type -> Type
JSONType :: Type

-- | A parsed expression.
data Expression
VariableExpression :: Variable -> Expression
LambdaExpression :: Variable -> Expression -> Expression
ApplicationExpression :: Expression -> Expression -> Expression
InfixExpression :: Expression -> Variable -> Expression -> Expression
IfExpression :: Expression -> Expression -> Expression -> Expression
SubscriptExpression :: Subscripted -> [Subscript] -> Expression
RecordExpression :: HashMap Text Expression -> Expression
ArrayExpression :: Vector Expression -> Expression
ConstantExpression :: Constant -> Expression
data Subscripted
WildcardSubscripted :: Subscripted
ExpressionSubscripted :: Expression -> Subscripted
data Subscript
PropertySubscript :: Text -> Subscript
ExpressionSubscript :: Expression -> Subscript

-- | Desugared core AST.
data Core
VariableCore :: Variable -> Core
LambdaCore :: Variable -> Core -> Core
ApplicationCore :: Core -> Core -> Core
IfCore :: Core -> Core -> Core -> Core
EvalCore :: (Core -> Core) -> Core
RecordCore :: HashMap Text Core -> Core
ArrayCore :: Vector Core -> Core
ConstantCore :: Constant -> Core
data Compare
ConstantCompare :: Constant -> Compare
VectorCompare :: Vector Compare -> Compare
RecordCompare :: [(Text, Compare)] -> Compare
coreToCompare :: Core -> Compare

-- | A self-evaluating constant.
data Constant
StringConstant :: Text -> Constant
NumberConstant :: Scientific -> Constant
BoolConstant :: Bool -> Constant
NullConstant :: Constant

-- | A type variable, generated by the type system.
newtype TypeVariable
TypeVariable :: Int -> TypeVariable

-- | A value variable, inputted by the programmer.
newtype Variable
Variable :: Text -> Variable
data Token
If :: Token
Then :: Token
Else :: Token
Case :: Token
Of :: Token
Backslash :: Token
RightArrow :: Token
Dollar :: Token
OpenParen :: Token
CloseParen :: Token
OpenBracket :: Token
CloseBracket :: Token
VariableToken :: !Text -> Token
StringToken :: !Text -> Token
Operator :: !Text -> Token
Period :: Token
Comma :: Token
Integer :: !Integer -> Token
Decimal :: !Double -> Token
OpenBrace :: Token
CloseBrace :: Token
Colon :: Token
NonIndentedNewline :: Token
Bar :: Token
TrueToken :: Token
FalseToken :: Token
NullToken :: Token
data Location
Location :: !Int -> !Int -> !Int -> !Int -> Location
[locationStartLine] :: Location -> !Int
[locationStartColumn] :: Location -> !Int
[locationEndLine] :: Location -> !Int
[locationEndColumn] :: Location -> !Int
data Definition
Definition :: Variable -> Text -> Type -> Core -> Definition
[definitionName] :: Definition -> Variable
[definitionDoc] :: Definition -> Text
[definitionType] :: Definition -> Type
[definitionCore] :: Definition -> Core
instance GHC.Classes.Eq JL.Types.Compare
instance GHC.Classes.Eq JL.Types.Constant
instance GHC.Classes.Eq JL.Types.Expression
instance GHC.Classes.Eq JL.Types.Location
instance GHC.Classes.Eq JL.Types.Subscript
instance GHC.Classes.Eq JL.Types.Subscripted
instance GHC.Classes.Eq JL.Types.Token
instance GHC.Classes.Eq JL.Types.Type
instance GHC.Classes.Eq JL.Types.TypeVariable
instance GHC.Classes.Eq JL.Types.Variable
instance GHC.Internal.Exception.Type.Exception JL.Types.ParseException
instance GHC.Classes.Ord JL.Types.Compare
instance GHC.Classes.Ord JL.Types.Constant
instance GHC.Classes.Ord JL.Types.Token
instance GHC.Classes.Ord JL.Types.Type
instance GHC.Classes.Ord JL.Types.TypeVariable
instance GHC.Classes.Ord JL.Types.Variable
instance GHC.Internal.Show.Show JL.Types.Constant
instance GHC.Internal.Show.Show JL.Types.Expression
instance GHC.Internal.Show.Show JL.Types.Location
instance GHC.Internal.Show.Show JL.Types.ParseException
instance GHC.Internal.Show.Show JL.Types.Subscript
instance GHC.Internal.Show.Show JL.Types.Subscripted
instance GHC.Internal.Show.Show JL.Types.Token
instance GHC.Internal.Show.Show JL.Types.Type
instance GHC.Internal.Show.Show JL.Types.TypeVariable
instance GHC.Internal.Show.Show JL.Types.Variable


-- | Duet syntax tokenizer.
module JL.Tokenizer
tokenize :: FilePath -> Text -> Either ParseError [(Token, Location)]
tokensTokenizer :: Parser [(Token, Location)]
tokenTokenizer :: [Char] -> Parser (Token, Location)
spaces1 :: Parser ()
ellipsis :: Int -> [Char] -> [Char]
specialParsing :: (t1 -> t) -> Parser t1 -> String -> Parser (t, Location)
atom :: t -> String -> Parser (t, Location)
atomThenSpace :: t -> String -> Parser (t, Location)
parsing :: (Text -> t) -> Parser Text -> String -> Parser (t, Location)
parseNumbers :: [a] -> Parser (Token, Location)
smartQuotes :: [Char] -> [Char]
equalToken :: Token -> TokenParser Location

-- | Consume the given predicate from the token stream.
satisfyToken :: (Token -> Bool) -> TokenParser (Token, Location)

-- | The parser <tt>anyToken</tt> accepts any kind of token. It is for
--   example used to implement <a>eof</a>. Returns the accepted token.
anyToken :: TokenParser (Token, Location)

-- | Consume the given predicate from the token stream.
consumeToken :: (Token -> Maybe a) -> TokenParser (a, Location)

-- | Make a string out of the token, for error message purposes.
tokenString :: (Token, Location) -> [Char]
tokenStr :: Token -> [Char]

-- | Update the position by the token.
tokenPosition :: SourcePos -> (Token, Location) -> t -> SourcePos
type TokenParser e = forall s (m :: Type -> Type). Stream s m (Token, Location) => ParsecT s Int m e

-- | <tt>notFollowedBy p</tt> only succeeds when parser <tt>p</tt> fails.
--   This parser does not consume any input. This parser can be used to
--   implement the 'longest match' rule. For example, when recognizing
--   keywords (for example <tt>let</tt>), we want to make sure that a
--   keyword is not followed by a legal identifier character, in which case
--   the keyword is actually an identifier (for example <tt>lets</tt>). We
--   can program this behaviour as follows:
--   
--   <pre>
--   keywordLet  = try (do{ string "let"
--                        ; notFollowedBy alphaNum
--                        })
--   </pre>
notFollowedBy' :: TokenParser (Token, Location) -> TokenParser ()

-- | This parser only succeeds at the end of the input. This is not a
--   primitive parser but it is defined using <a>notFollowedBy</a>.
--   
--   <pre>
--   eof  = notFollowedBy anyToken &lt;?&gt; "end of input"
--   </pre>
endOfTokens :: TokenParser ()
curlyQuotes :: [Char] -> [Char]

module JL.Printer

-- | Pretty printing for type.
prettyType :: Type -> Text

-- | Pretty printing for expression.
prettyExp :: Expression -> Text

-- | Pretty printing for core.
prettyCore :: Core -> Text
prettyConstant :: Constant -> Text
prettySubcript :: Subscript -> Text
prettyVariable :: Variable -> Text

module JL.Serializer
coreToNumber :: Core -> Scientific
coreToString :: Core -> Text
coreToArray :: Core -> Vector Core
coreToValue :: Core -> Value
constantToValue :: Constant -> Value
valueToCore :: Value -> Core
valueToExpression :: Value -> Expression

module JL.Parser
parseText :: MonadThrow m => SourceName -> Text -> m Expression
expressionParser :: TokenParser Expression
parens :: TokenParser a -> TokenParser a
varParser :: TokenParser Expression
ifParser :: TokenParser Expression
atomic :: TokenParser Expression
stringParser :: TokenParser Expression
lambda :: TokenParser Expression
funcParam :: TokenParser Variable

module JL.Interpreter

-- | Eval core.
eval :: Core -> Core

-- | Substitute name in function body.
subst :: Variable -> Core -> Core -> Core

-- | Remove syntactic sugar and convert into executable form.
desugar :: Expression -> Core

module JL.Inferer

-- | Get the type of the expression.
infer :: Map Variable Type -> Expression -> [TypeVariable] -> Type

-- | Check the exp with the given context.
check :: MonadState [TypeVariable] m => Map Variable Type -> Expression -> m (Type, Set (Type, Type))

-- | Generate a fresh type variable.
generateTypeVariable :: MonadState [TypeVariable] m => m TypeVariable

-- | Unify the list of constraints.
unify :: Monad m => [(Type, Type)] -> m (Map TypeVariable Type)

-- | Unify a type variable for two types.
unifyVariable :: Monad m => TypeVariable -> [(Type, Type)] -> Type -> Type -> m (Map TypeVariable Type)

-- | Occurs check.
occurs :: TypeVariable -> Type -> Bool

-- | Substitute the unified type into the constraints.
substitute :: Map TypeVariable Type -> [(Type, Type)] -> [(Type, Type)]

-- | Apply a substitution to a type.
replace :: Map TypeVariable Type -> Type -> Type

-- | Quote something for showing to the programmer.
quote :: Text -> Text

module JL.Functions

-- | The typing context.
context :: Map Variable Type

-- | Bindings available in scope.
scope :: Map Variable Core

-- | All functions.
functions :: [(Text, [Definition])]


-- | Main library entry point.
module JL
repl :: Text -> ByteString -> IO ()
