-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An Interpreter for the Programming Language Egison -- -- An interpreter for the programming language Egison. A feature of -- Egison is the strong pattern match facility. With Egison, you can -- represent pattern matching for unfree data intuitively, especially for -- collection data, such as lists, multisets, sets, and so on. This -- package include sample Egison program codes *-test.egi in -- sample/ directory. This package also include Emacs Lisp file -- egison-mode.el in elisp/ directory. @package egison @version 2.3.6 module Language.Egison.Types data EgisonError NumArgs :: Integer -> [EgisonVal] -> EgisonError TypeMismatch :: String -> [EgisonVal] -> EgisonError Parser :: ParseError -> EgisonError BadSpecialForm :: String -> [EgisonVal] -> EgisonError NotFunction :: String -> String -> EgisonError UnboundVar :: String -> String -> EgisonError DivideByZero :: EgisonError NotImplemented :: String -> EgisonError InternalError :: String -> EgisonError Default :: String -> EgisonError showError :: EgisonError -> String type ThrowsError = Either EgisonError trapError :: (MonadError e m, Show e) => m String -> m String extractValue :: ThrowsError a -> a type IOThrowsError = ErrorT EgisonError IO liftThrows :: ThrowsError a -> IOThrowsError a runIOThrowsREPL :: IOThrowsError String -> IO String runIOThrows :: IOThrowsError String -> IO (Maybe String) data TopExpr Define :: String -> EgisonExpr -> TopExpr Test :: EgisonExpr -> TopExpr Execute :: [String] -> TopExpr LoadFile :: String -> TopExpr Load :: String -> TopExpr data EgisonExpr CharExpr :: Char -> EgisonExpr StringExpr :: String -> EgisonExpr BoolExpr :: Bool -> EgisonExpr NumberExpr :: Integer -> EgisonExpr FloatExpr :: Double -> EgisonExpr VarExpr :: String -> [EgisonExpr] -> EgisonExpr MacroVarExpr :: String -> [EgisonExpr] -> EgisonExpr PatVarOmitExpr :: EgisonExpr -> EgisonExpr VarOmitExpr :: EgisonExpr -> EgisonExpr PatVarExpr :: String -> [EgisonExpr] -> EgisonExpr WildCardExpr :: EgisonExpr ValuePatExpr :: EgisonExpr -> EgisonExpr CutPatExpr :: EgisonExpr -> EgisonExpr NotPatExpr :: EgisonExpr -> EgisonExpr AndPatExpr :: [EgisonExpr] -> EgisonExpr OrPatExpr :: [EgisonExpr] -> EgisonExpr PredPatExpr :: EgisonExpr -> [EgisonExpr] -> EgisonExpr InductiveDataExpr :: String -> [EgisonExpr] -> EgisonExpr TupleExpr :: [InnerExpr] -> EgisonExpr CollectionExpr :: [InnerExpr] -> EgisonExpr ArrayExpr :: [ArrayElementExpr] -> EgisonExpr FuncExpr :: Args -> EgisonExpr -> EgisonExpr MacroExpr :: [String] -> EgisonExpr -> EgisonExpr LoopExpr :: String -> String -> EgisonExpr -> EgisonExpr -> EgisonExpr -> EgisonExpr ParamsExpr :: String -> EgisonExpr -> EgisonExpr -> EgisonExpr IfExpr :: EgisonExpr -> EgisonExpr -> EgisonExpr -> EgisonExpr LetExpr :: Bindings -> EgisonExpr -> EgisonExpr LetRecExpr :: RecursiveBindings -> EgisonExpr -> EgisonExpr DoExpr :: Bindings -> EgisonExpr -> EgisonExpr TypeExpr :: DestructInfoExpr -> EgisonExpr MatchExpr :: EgisonExpr -> EgisonExpr -> [MatchClause] -> EgisonExpr MatchAllExpr :: EgisonExpr -> EgisonExpr -> MatchClause -> EgisonExpr GenerateArrayExpr :: EgisonExpr -> EgisonExpr -> EgisonExpr ApplyExpr :: EgisonExpr -> EgisonExpr -> EgisonExpr SomethingExpr :: EgisonExpr data ArrayElementExpr AElementExpr :: EgisonExpr -> ArrayElementExpr AInnerArrayExpr :: [ArrayElementExpr] -> ArrayElementExpr type ArgsExpr = Args type MatchClause = (EgisonExpr, EgisonExpr) data PrimitivePatPattern PPWildCard :: PrimitivePatPattern PPValuePat :: String -> PrimitivePatPattern PPInductivePat :: String -> [PrimitivePatPattern] -> PrimitivePatPattern data PrimitivePattern PWildCard :: PrimitivePattern PPatVar :: String -> PrimitivePattern PInductivePat :: String -> [PrimitivePattern] -> PrimitivePattern PEmptyPat :: PrimitivePattern PConsPat :: PrimitivePattern -> PrimitivePattern -> PrimitivePattern PSnocPat :: PrimitivePattern -> PrimitivePattern -> PrimitivePattern PPatBool :: Bool -> PrimitivePattern PPatChar :: Char -> PrimitivePattern PPatNumber :: Integer -> PrimitivePattern PPatFloat :: Double -> PrimitivePattern data InnerExpr ElementExpr :: EgisonExpr -> InnerExpr SubCollectionExpr :: EgisonExpr -> InnerExpr type Bindings = [(Args, EgisonExpr)] type RecursiveBindings = [(String, EgisonExpr)] type DestructInfoExpr = [(PrimitivePatPattern, EgisonExpr, [(PrimitivePattern, EgisonExpr)])] type ObjectRef = IORef Object data Object Closure :: Env -> EgisonExpr -> Object Value :: EgisonVal -> Object Intermidiate :: IntermidiateVal -> Object Loop :: String -> String -> ObjectRef -> EgisonExpr -> EgisonExpr -> Object data EgisonVal World :: [Action] -> EgisonVal Char :: Char -> EgisonVal String :: String -> EgisonVal Bool :: Bool -> EgisonVal Number :: Integer -> EgisonVal Float :: Double -> EgisonVal WildCard :: EgisonVal PatVar :: String -> [Integer] -> EgisonVal ValuePat :: ObjectRef -> EgisonVal PredPat :: ObjectRef -> [ObjectRef] -> EgisonVal CutPat :: ObjectRef -> EgisonVal NotPat :: ObjectRef -> EgisonVal AndPat :: [ObjectRef] -> EgisonVal OrPat :: [ObjectRef] -> EgisonVal InductiveData :: String -> [EgisonVal] -> EgisonVal Tuple :: [EgisonVal] -> EgisonVal Collection :: [EgisonVal] -> EgisonVal Array :: Integer -> [Integer] -> (Array Integer EgisonVal) -> EgisonVal Type :: DestructInfo -> EgisonVal Func :: Args -> EgisonExpr -> Env -> EgisonVal Macro :: [String] -> EgisonExpr -> EgisonVal PrimitiveFunc :: ([EgisonVal] -> ThrowsError EgisonVal) -> EgisonVal IOFunc :: ([EgisonVal] -> IOThrowsError EgisonVal) -> EgisonVal Port :: String -> Handle -> EgisonVal Something :: EgisonVal EOF :: EgisonVal data IntermidiateVal IInductiveData :: String -> [ObjectRef] -> IntermidiateVal ITuple :: [InnerValRef] -> IntermidiateVal ICollection :: [InnerValRef] -> IntermidiateVal data Action OpenInputPort :: String -> Action OpenOutputPort :: String -> Action ClosePort :: String -> Action FlushPort :: String -> Action ReadFromPort :: String -> String -> Action WriteToPort :: String -> String -> Action data Args AVar :: String -> Args ATuple :: [Args] -> Args data InnerValRef IElement :: ObjectRef -> InnerValRef ISubCollection :: ObjectRef -> InnerValRef type DestructInfo = [(PrimitivePatPattern, ObjectRef, [(Env, PrimitivePattern, EgisonExpr)])] type VarExpr = (String, [EgisonExpr]) type Var = (String, [Integer]) type FrameList = [(Var, ObjectRef)] type Frame = Map Var ObjectRef type FrameRef = IORef Frame data Env Environment :: (Maybe Env) -> FrameRef -> Env parentEnv :: Env -> (Maybe Env) topFrameRef :: Env -> FrameRef nullEnv :: IO Env makeClosure :: Env -> EgisonExpr -> IO ObjectRef makeInnerValRef :: Env -> InnerExpr -> IO InnerValRef data MatchFlag MAll :: MatchFlag MOne :: MatchFlag data PClosure PClosure :: FrameList -> ObjectRef -> PClosure pcFrame :: PClosure -> FrameList pcBody :: PClosure -> ObjectRef data MAtom MAtom :: PClosure -> ObjectRef -> ObjectRef -> MAtom pClosure :: MAtom -> PClosure maTyp :: MAtom -> ObjectRef maTarget :: MAtom -> ObjectRef data MState MState :: FrameList -> [MAtom] -> MState msFrame :: MState -> FrameList mAtoms :: MState -> [MAtom] -- | Convert a list of Egison objects into a space-separated string unwordsList :: Show a => [a] -> String -- | Convert a list of Egison expressions into a space-separated string unwordsExpr :: [EgisonExpr] -> String -- | Convert a list of Egison expressions into a '_'-separated string unwordsNumExprs :: [EgisonExpr] -> String -- | Convert a list of Egison objects into a '_'-separated string unwordsNums :: Show a => [a] -> String showVar :: (String, [Integer]) -> String showBindings :: Bindings -> String showRecursiveBindings :: RecursiveBindings -> String showExpr :: EgisonExpr -> String eqv :: [EgisonVal] -> ThrowsError EgisonVal eqValList :: [EgisonVal] -> [EgisonVal] -> Bool eqVal :: EgisonVal -> EgisonVal -> Bool showArray :: [Integer] -> [EgisonVal] -> String showVal :: EgisonVal -> String showIVal :: IntermidiateVal -> String showObj :: Object -> String showFrameList :: FrameList -> String stringToCharCollection :: String -> IO EgisonVal nth :: Integer -> [a] -> a integersToInteger :: [Integer] -> [Integer] -> Integer multiplyList :: [Integer] -> Integer indexList :: [Integer] -> [[Integer]] betweenNumbers :: Integer -> Integer -> [Integer] tupleToList :: EgisonVal -> [EgisonVal] instance Show PrimitivePatPattern instance Show PrimitivePattern instance Show Args instance Show EgisonExpr instance Show InnerExpr instance Show ArrayElementExpr instance Show TopExpr instance Show Object instance Show IntermidiateVal instance Show EgisonVal instance Eq EgisonVal instance Error EgisonError instance Show EgisonError module Language.Egison.Variables -- | Show the contents of an environment printEnv :: Env -> IO String -- | Create a copy of an environment copyEnv :: Env -> IO Env -- | Extend given environment by binding a series of values to a new -- environment. extendEnv :: Env -> [(Var, ObjectRef)] -> IO Env makeLetRecFrame :: Env -> [(String, EgisonExpr)] -> IO FrameRef -- | Extend given environment by binding a series of values to a new -- environment for letrec. extendLetRec :: Env -> [(String, EgisonExpr)] -> IO Env -- | Recursively search environments to find one that contains the given -- variable. findEnv :: Env -> Var -> IO (Maybe Env) -- | Determine if a variable is bound isBound :: Env -> Var -> IO Bool -- | Determine if a variable is bound or a parent of the given environment. isRecBound :: Env -> Var -> IO Bool getVarFromFrame :: Frame -> Var -> IOThrowsError ObjectRef -- | Retrieve the value of a variable defined getVar :: Env -> Var -> IOThrowsError ObjectRef -- | Bind a variable defineVar :: Env -> Var -> ObjectRef -> IOThrowsError () module Language.Egison.Macro type MacroFrame = Map String EgisonExpr getExpr :: MacroFrame -> String -> Maybe EgisonExpr expandMacro :: MacroFrame -> EgisonExpr -> IOThrowsError EgisonExpr expandMacroMatchClause :: MacroFrame -> MatchClause -> IOThrowsError MatchClause expandMacroInnerExpr :: MacroFrame -> InnerExpr -> IOThrowsError InnerExpr module Language.Egison.Parser egisonDef :: LanguageDef () lexer :: GenTokenParser String () Identity dot :: ParsecT String () Identity String parens :: ParsecT String () Identity a -> ParsecT String () Identity a brackets :: ParsecT String () Identity a -> ParsecT String () Identity a braces :: ParsecT String () Identity a -> ParsecT String () Identity a angles :: ParsecT String () Identity a -> ParsecT String () Identity a identifier :: ParsecT String () Identity String whiteSpace :: ParsecT String () Identity () lexeme :: ParsecT String () Identity a -> ParsecT String () Identity a symbol :: Parser Char symbol2 :: Parser Char parseBool :: Parser EgisonExpr parseBool2 :: Parser Bool parseChar :: Parser EgisonExpr parseChar2 :: Parser Char parseOctalNumber :: Parser EgisonExpr parseBinaryNumber :: Parser EgisonExpr parseHexNumber :: Parser EgisonExpr parseDecimalNumber :: Parser EgisonExpr parseDecimalNumberMaybeExponent :: Parser EgisonExpr parseNumber :: Parser EgisonExpr parseNumber2 :: Parser Integer -- | Parse a floating point number parseRealNumber :: Parser EgisonExpr parseRealNumber2 :: Parser Double -- | Parse the exponent section of a floating point number in scientific -- notation. Eg e10 from 1.0e10 parseNumberExponent :: EgisonExpr -> Parser EgisonExpr parseEscapedChar :: GenParser Char st Char parseString2 :: Parser String parseString :: Parser EgisonExpr parseIndexNums :: Parser [EgisonExpr] parseInnerExp :: Parser InnerExpr parsePatVar2 :: Parser VarExpr parsePatVar :: Parser EgisonExpr parseMacroVarExpr :: Parser EgisonExpr parsePatVarOmitExpr :: Parser EgisonExpr parseVarOmitExpr :: Parser EgisonExpr parseArgs :: Parser ArgsExpr parseBindings :: Parser Bindings parseRecursiveBindings :: Parser RecursiveBindings parseVar :: Parser EgisonExpr parseWildCard :: Parser EgisonExpr parseCutPat :: Parser EgisonExpr parseNotPat :: Parser EgisonExpr parseValuePat :: Parser EgisonExpr parseInnerExpr :: Parser InnerExpr parsePattern :: Parser EgisonExpr parseDestructInfoExpr :: Parser DestructInfoExpr parseDestructClause :: Parser (PrimitivePatPattern, EgisonExpr, [(PrimitivePattern, EgisonExpr)]) parseDestructClause2 :: Parser (PrimitivePattern, EgisonExpr) parsePrimitivePatPattern :: Parser PrimitivePatPattern parsePrimitivePattern :: Parser PrimitivePattern parseMatchClause :: Parser MatchClause parseArrayElementExpr :: Parser ArrayElementExpr -- | Parse an expression parseExpr :: Parser EgisonExpr parseTopExpr :: Parser TopExpr mainParser :: Parser TopExpr -- | Use a parser to parse the given text, throwing an error if there is a -- problem parsing the text. readOrThrow :: Parser a -> String -> ThrowsError a -- | Parse an top expression from a string of text readTopExpr :: String -> ThrowsError TopExpr -- | Parse an expression from a string of text readExpr :: String -> ThrowsError EgisonExpr -- | Parse many top expressions from a string of text readTopExprList :: String -> ThrowsError [TopExpr] module Language.Egison.Primitives makePort :: IOMode -> [EgisonVal] -> IOThrowsError EgisonVal closePort :: [EgisonVal] -> IOThrowsError EgisonVal writeChar :: [EgisonVal] -> IOThrowsError EgisonVal writeString :: [EgisonVal] -> IOThrowsError EgisonVal writeStringLine :: [EgisonVal] -> IOThrowsError EgisonVal write :: [EgisonVal] -> IOThrowsError EgisonVal flushStdout :: [EgisonVal] -> IOThrowsError EgisonVal readChar :: [EgisonVal] -> IOThrowsError EgisonVal readLine :: [EgisonVal] -> IOThrowsError EgisonVal readFromStdin :: [EgisonVal] -> IOThrowsError EgisonVal writeCharToPort :: [EgisonVal] -> IOThrowsError EgisonVal writeStringToPort :: [EgisonVal] -> IOThrowsError EgisonVal writeStringLineToPort :: [EgisonVal] -> IOThrowsError EgisonVal writeToPort :: [EgisonVal] -> IOThrowsError EgisonVal flushPort :: [EgisonVal] -> IOThrowsError EgisonVal readCharFromPort :: [EgisonVal] -> IOThrowsError EgisonVal readLineFromPort :: [EgisonVal] -> IOThrowsError EgisonVal readFromPort :: [EgisonVal] -> IOThrowsError EgisonVal hGetExpr :: Handle -> IOThrowsError String countParens :: String -> Bool exprToVal :: EgisonExpr -> ThrowsError EgisonVal innerExprsToVals :: [InnerExpr] -> ThrowsError [EgisonVal] module Language.Egison.Numerical boolBinop :: (Bool -> Bool -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal numericSglop :: (Integer -> Integer) -> [EgisonVal] -> ThrowsError EgisonVal floatSglop :: (Double -> Double) -> [EgisonVal] -> ThrowsError EgisonVal floatNumSglop :: (Double -> Integer) -> [EgisonVal] -> ThrowsError EgisonVal numericBinop :: (Integer -> Integer -> Integer) -> [EgisonVal] -> ThrowsError EgisonVal floatBinop :: (Double -> Double -> Double) -> [EgisonVal] -> ThrowsError EgisonVal stringBinop :: (String -> String -> String) -> [EgisonVal] -> ThrowsError EgisonVal charBoolBinop :: (Char -> Char -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal strBoolBinop :: (String -> String -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal numBoolBinop :: (Integer -> Integer -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal floatBoolBinop :: (Double -> Double -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal foldlM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a foldl1M :: Monad m => (a -> a -> m a) -> [a] -> m a floatRound, floatTruncate, floatCeiling, floatFloor :: [EgisonVal] -> ThrowsError EgisonVal numSqrt, numExpt :: [EgisonVal] -> ThrowsError EgisonVal numExp :: [EgisonVal] -> ThrowsError EgisonVal numLog :: [EgisonVal] -> ThrowsError EgisonVal -- | Convert a float to a string; radix is optional, defaults to base 10 -- floatToString :: [EgisonVal] -> IOThrowsError EgisonVal -- floatToString [(Float n)] = liftIO $ stringToCharCollection $ show n -- floatToString [x] = throwError $ TypeMismatch number x -- floatToString badArgList = throwError $ NumArgs 1 badArgList isEgisonEOF :: [EgisonVal] -> ThrowsError EgisonVal -- | Extract an bool from the given value, throwing a type error if the -- wrong type is passed. unpackBool :: EgisonVal -> ThrowsError Bool -- | Extract an char from the given value, throwing a type error if the -- wrong type is passed. unpackChar :: EgisonVal -> ThrowsError Char -- | Extract an char from the given value, throwing a type error if the -- wrong type is passed. unpackString :: EgisonVal -> ThrowsError String -- | Extract an integer from the given value, throwing a type error if the -- wrong type is passed. unpackNum :: EgisonVal -> ThrowsError Integer -- | Extract an double from the given value, throwing a type error if the -- wrong type is passed. unpackFloat :: EgisonVal -> ThrowsError Double tupleToCollection :: [EgisonVal] -> ThrowsError EgisonVal collectionToTuple :: [EgisonVal] -> ThrowsError EgisonVal stringToChars :: [EgisonVal] -> ThrowsError EgisonVal charsToString :: [EgisonVal] -> ThrowsError EgisonVal arrayDimension :: [EgisonVal] -> ThrowsError EgisonVal arrayRange :: [EgisonVal] -> ThrowsError EgisonVal arraySize :: [EgisonVal] -> ThrowsError EgisonVal arrayKeys :: [EgisonVal] -> ThrowsError EgisonVal arrayIsRange :: [EgisonVal] -> ThrowsError EgisonVal arrayRef :: [EgisonVal] -> ThrowsError EgisonVal module Language.Egison.Core egisonVersion :: String -- | A utility function to display the egison console banner showBanner :: IO () -- | A utility function to display the egison console byebye message showByebyeMessage :: IO () -- | Load standard libraries into the given environment loadLibraries :: Env -> IO () -- | A utility function to escape backslashes in the given string escapeBackslashes :: String -> String evalString :: Env -> String -> IO String evalMain :: Env -> [String] -> IOThrowsError EgisonVal -- | Evaluate egison top expression that has already been loaded into -- haskell evalTopExpr :: Env -> TopExpr -> IOThrowsError String load :: Env -> String -> IOThrowsError () -- | Evaluate egison expression that has already been loaded into haskell eval :: Env -> EgisonExpr -> IOThrowsError EgisonVal iEval :: IntermidiateVal -> IOThrowsError EgisonVal innerRefsEval :: [InnerValRef] -> IOThrowsError [EgisonVal] cRefEval :: ObjectRef -> IOThrowsError EgisonVal cRefEval1 :: ObjectRef -> IOThrowsError Object cEval :: Object -> IOThrowsError EgisonVal cEval1 :: Object -> IOThrowsError Object cApply :: ObjectRef -> ObjectRef -> IOThrowsError EgisonVal cApply1 :: ObjectRef -> ObjectRef -> IOThrowsError Object expandLoop :: Env -> Object -> IOThrowsError Object -- | Extend given environment by binding a series of values to a new -- environment for let. extendLet :: Env -> [(Args, EgisonExpr)] -> IOThrowsError Env makeFrame :: Args -> ObjectRef -> IOThrowsError [(Var, ObjectRef)] tupleExprToExprList :: EgisonExpr -> ThrowsError [EgisonExpr] innerExprsToExprList :: [InnerExpr] -> ThrowsError [EgisonExpr] innerValRefsToObjRefs :: [InnerValRef] -> IOThrowsError [ObjectRef] patternMatch :: MatchFlag -> [MState] -> IOThrowsError [FrameList] inductiveMatch :: DestructInfo -> ObjectRef -> ObjectRef -> IOThrowsError ([ObjectRef], [ObjectRef], [[ObjectRef]]) primitivePatPatternMatch :: PrimitivePatPattern -> ObjectRef -> IOThrowsError (Maybe ([ObjectRef], FrameList)) primitivePatPatternMatchList :: [PrimitivePatPattern] -> [ObjectRef] -> IOThrowsError (Maybe ([ObjectRef], FrameList)) primitivePatternMatch :: PrimitivePattern -> ObjectRef -> IOThrowsError (Maybe FrameList) primitivePatternMatchList :: [PrimitivePattern] -> [ObjectRef] -> IOThrowsError (Maybe FrameList) objectRefToInnerRefs :: ObjectRef -> IOThrowsError [InnerValRef] isEmptyCollection :: ObjectRef -> IOThrowsError Bool isEmptyCollectionForSnoc :: ObjectRef -> IOThrowsError Bool consDestruct :: ObjectRef -> IOThrowsError (ObjectRef, ObjectRef) snocDestruct :: ObjectRef -> IOThrowsError (ObjectRef, ObjectRef) collectionToObjRefs :: ObjectRef -> IOThrowsError [ObjectRef] tupleToObjRefs :: ObjectRef -> IOThrowsError [ObjectRef] innerRefsToObjRefs :: [InnerValRef] -> IOThrowsError [ObjectRef] primitiveBindings :: IO Env constants :: [(String, EgisonVal)] ioPrimitives :: [(String, [EgisonVal] -> IOThrowsError EgisonVal)] primitives :: [(String, [EgisonVal] -> ThrowsError EgisonVal)]