-- 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.1.2 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 SymbolExpr :: String -> [EgisonExpr] -> EgisonExpr PatVarExpr :: String -> [EgisonExpr] -> EgisonExpr WildCardExpr :: EgisonExpr PatVarOmitExpr :: EgisonExpr -> EgisonExpr CutPatExpr :: EgisonExpr -> EgisonExpr NotPatExpr :: EgisonExpr -> EgisonExpr AndPatExpr :: [EgisonExpr] -> EgisonExpr OrPatExpr :: [EgisonExpr] -> EgisonExpr PredPatExpr :: String -> [EgisonExpr] -> EgisonExpr InductiveDataExpr :: String -> [EgisonExpr] -> EgisonExpr TupleExpr :: [InnerExpr] -> EgisonExpr CollectionExpr :: [InnerExpr] -> EgisonExpr FuncExpr :: Args -> 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 :: RecursiveBindings -> EgisonExpr TypeRefExpr :: EgisonExpr -> String -> EgisonExpr DestructorExpr :: DestructInfoExpr -> EgisonExpr MatchExpr :: EgisonExpr -> EgisonExpr -> [MatchClause] -> EgisonExpr MatchAllExpr :: EgisonExpr -> EgisonExpr -> MatchClause -> EgisonExpr ApplyExpr :: EgisonExpr -> EgisonExpr -> EgisonExpr type ArgsExpr = Args type MatchClause = (EgisonExpr, EgisonExpr) 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 = [(String, 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 PredPat :: String -> [ObjectRef] -> EgisonVal CutPat :: ObjectRef -> EgisonVal NotPat :: ObjectRef -> EgisonVal AndPat :: [ObjectRef] -> EgisonVal OrPat :: [ObjectRef] -> EgisonVal InductiveData :: String -> [EgisonVal] -> EgisonVal Tuple :: [InnerVal] -> EgisonVal Collection :: [InnerVal] -> EgisonVal Type :: Frame -> EgisonVal Destructor :: DestructInfo -> EgisonVal Func :: Args -> EgisonExpr -> Env -> EgisonVal PrimitiveFunc :: ([EgisonVal] -> ThrowsError EgisonVal) -> EgisonVal IOFunc :: ([EgisonVal] -> IOThrowsError EgisonVal) -> EgisonVal Port :: String -> Handle -> 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 InnerVal Element :: EgisonVal -> InnerVal SubCollection :: EgisonVal -> InnerVal innerValsToList :: [InnerVal] -> [EgisonVal] tupleToList :: EgisonVal -> [EgisonVal] collectionToList :: EgisonVal -> [EgisonVal] valsToObjRefList :: [EgisonVal] -> IO [ObjectRef] makeTupleFromValList :: [EgisonVal] -> EgisonVal makeCollectionFromValList :: [EgisonVal] -> EgisonVal data InnerValRef IElement :: ObjectRef -> InnerValRef ISubCollection :: ObjectRef -> InnerValRef type DestructInfo = [(String, 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 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 eqVal :: EgisonVal -> EgisonVal -> Bool showVal :: EgisonVal -> String showInnerVals :: [InnerVal] -> String showIVal :: IntermidiateVal -> String showObj :: Object -> String showFrameList :: FrameList -> String stringToCharCollection :: String -> IO EgisonVal instance Show Object instance Show IntermidiateVal instance Show EgisonVal instance Eq EgisonVal instance Show EgisonExpr 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.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 -- | Parser for Integer, base 10 parseDecimalNumber :: Parser EgisonExpr -- | Parser for a base 10 Integer that will also check to see if the number -- is followed by an exponent (scientific notation). If so, the integer -- is converted to a float of the given magnitude. parseDecimalNumberMaybeExponent :: Parser EgisonExpr -- | Parse an integer in any base 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 parseSymbol2 :: Parser VarExpr parseSymbol :: 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 (String, EgisonExpr, [(PrimitivePattern, EgisonExpr)]) parseDestructClause2 :: Parser (PrimitivePattern, EgisonExpr) parsePrimitivePattern :: Parser PrimitivePattern parseMatchClause :: Parser MatchClause -- | 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.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 numBoolBinop :: (Integer -> Integer -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal floatBoolBinop :: (Double -> Double -> Bool) -> [EgisonVal] -> ThrowsError EgisonVal 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 -- -- Extract an integer from the given value, throwing a type error if the -- wrong type is passed. unpackBool :: EgisonVal -> ThrowsError Bool -- | 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 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 -> IO String countParens :: String -> Bool exprToVal :: EgisonExpr -> ThrowsError EgisonVal innerExprToInnerVal :: InnerExpr -> ThrowsError InnerVal module Language.Egison.Core -- | egison version number 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 innerValRefEval :: InnerValRef -> IOThrowsError InnerVal cRefEval :: ObjectRef -> IOThrowsError EgisonVal cRefEval1 :: ObjectRef -> IOThrowsError Object cEval :: Object -> IOThrowsError EgisonVal cEval1 :: Object -> IOThrowsError Object 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)] innerValRefsToObjRefList :: [InnerValRef] -> IOThrowsError [ObjectRef] patternMatch :: MatchFlag -> [MState] -> IOThrowsError [FrameList] inductiveMatch :: DestructInfo -> String -> ObjectRef -> IOThrowsError (ObjectRef, ObjectRef) primitivePatternMatch :: PrimitivePattern -> ObjectRef -> IOThrowsError (Maybe FrameList) primitivePatternMatchList :: [PrimitivePattern] -> [ObjectRef] -> IOThrowsError (Maybe FrameList) isEmptyCollection :: ObjectRef -> IOThrowsError Bool isEmptyInnerRefs :: [InnerValRef] -> IOThrowsError Bool isEmptyInnerVals :: [InnerVal] -> IOThrowsError Bool consDestruct :: ObjectRef -> IOThrowsError (ObjectRef, ObjectRef) consDestructInnerRefs :: [InnerValRef] -> IOThrowsError (ObjectRef, ObjectRef) consDestructInnerVals :: [InnerVal] -> IOThrowsError (ObjectRef, ObjectRef) snocDestruct :: ObjectRef -> IOThrowsError (ObjectRef, ObjectRef) snocDestructInnerRefs :: [InnerValRef] -> IOThrowsError (ObjectRef, ObjectRef) snocDestructInnerVals :: [InnerVal] -> IOThrowsError (ObjectRef, ObjectRef) collectionToObjRefList :: ObjectRef -> IOThrowsError [ObjectRef] tupleToObjRefList :: ObjectRef -> IOThrowsError [ObjectRef] innerRefsToObjRefList :: [InnerValRef] -> IOThrowsError [ObjectRef] innerValsToObjRefList :: [InnerVal] -> IOThrowsError [ObjectRef] primitiveBindings :: IO Env constants :: [(String, EgisonVal)] ioPrimitives :: [(String, [EgisonVal] -> IOThrowsError EgisonVal)] primitives :: [(String, [EgisonVal] -> ThrowsError EgisonVal)]