packages feed

egison 2.1.13 → 2.1.14

raw patch · 5 files changed

+51/−24 lines, 5 filesdep +regex-posixPVP ok

version bump matches the API change (PVP)

Dependencies added: regex-posix

API changes (from Hackage documentation)

+ Language.Egison.Types: eqValList :: [EgisonVal] -> [EgisonVal] -> Bool

Files

egison.cabal view
@@ -1,5 +1,5 @@ Name:                egison-Version:             2.1.13+Version:             2.1.14 Synopsis:            An Interpreter for the Programming Language Egison Description:         An interpreter for the programming language Egison.                      A feature of Egison is the strong pattern match facility.@@ -38,7 +38,7 @@  Executable egison   Main-is:             egisoni.hs-  Build-depends:       egison, base >= 4.0 && < 5, array, containers, haskeline, transformers, mtl, parsec >= 3.0, directory, ghc, ghc-paths+  Build-depends:       egison, base >= 4.0 && < 5, array, containers, haskeline, transformers, mtl, parsec >= 3.0, directory, ghc, ghc-paths, regex-posix   Other-modules:       Paths_egison   Hs-Source-Dirs:      hs-src/Interpreter   
hs-src/Interpreter/egisoni.hs view
@@ -1,6 +1,7 @@ module Main where import Paths_egison import Language.Egison.Core      -- Egison Interpreter+import Language.Egison.Parser import Language.Egison.Types     -- Egison data types import Language.Egison.Variables -- Egison variable operations --import Control.Monad (when)@@ -8,6 +9,7 @@ import System.IO import System.Environment import System.Console.Haskeline+import Text.Regex.Posix  main :: IO () main = do args <- getArgs@@ -52,20 +54,27 @@                 Just "" -> if input0 == ""                              then loop env "> " ""                              else loop env "  " (input0 ++ "\n")-                Just input ->-                  let newInput = input0 ++ input in-                    if (countParens newInput)-                      then do result <- liftIO (evalString env newInput)-                              if (length result) > 0-                                then do outputStrLn result-                                        loop env "> " ""-                                else loop env "> " ""-                      else loop env "  " newInput+                Just input -> do+                  let newInput = input0 ++ input+                  let eTopExpr = readTopExpr newInput+                  case eTopExpr of+                    Left e -> do+                      if show e =~ "unexpected end of input" -- Is this really OK?+                        then loop env "  " $ newInput ++ "\n"+                        else do liftIO $ putStrLn $ show e+                                loop env "> " ""+                    Right _ -> do+                      result <- liftIO (evalString env newInput)+                      if (length result) > 0+                        then do outputStrLn result+                                loop env "> " ""+                        else loop env "> " "" -countParens :: String -> Bool-countParens str = let countOpen = length $ filter ((==) '(') str in-                  let countClose = length $ filter  ((==) ')') str in-                    (countOpen > 0) && (countOpen <= countClose)+--countParens :: String -> Bool+--countParens str = let countOpen = length $ filter ((==) '(') str in+--                  let countClose = length $ filter  ((==) ')') str in+--                    (countOpen > 0) && (countOpen <= countClose)+ -- End REPL Section  -- Begin Util section, of generic functions
hs-src/Language/Egison/Core.hs view
@@ -850,11 +850,13 @@               ("sqrt", numSqrt),               ("expt", numExpt), -              ("eq?", numBoolBinop (==)),-              ("lt?", numBoolBinop (<)),-              ("lte?", numBoolBinop (<=)),-              ("gt?", numBoolBinop (>)),-              ("gte?", numBoolBinop (>=)),+              ("eq?", eqv),+              +              ("eq-n?", numBoolBinop (==)),+              ("lt-n?", numBoolBinop (<)),+              ("lte-n?", numBoolBinop (<=)),+              ("gt-n?", numBoolBinop (>)),+              ("gte-n?", numBoolBinop (>=)),                ("eq-f?", floatBoolBinop (==)),               ("lt-f?", floatBoolBinop (<)),
hs-src/Language/Egison/Types.hs view
@@ -338,8 +338,24 @@ eqv [(Float arg1), (Float arg2)] = return $ Bool $ arg1 == arg2 eqv [(Char arg1), (Char arg2)] = return $ Bool $ arg1 == arg2 eqv [(String arg1), (String arg2)] = return $ Bool $ arg1 == arg2+eqv [(InductiveData cons1 args1), (InductiveData cons2 args2)] =+  if (cons1 == cons2)+    then return $ Bool $ eqValList args1 args2+    else return $ Bool False+eqv [(Tuple innerVals1), (Tuple innerVals2)] =+  return $ Bool $ eqValList (innerValsToList innerVals1) (innerValsToList innerVals2)+eqv [(Collection innerVals1), (Collection innerVals2)] =+  return $ Bool $ eqValList (innerValsToList innerVals1) (innerValsToList innerVals2) eqv [_, _] = return $ Bool False eqv badArgList = throwError $ NumArgs 2 badArgList++eqValList :: [EgisonVal] -> [EgisonVal] -> Bool+eqValList [] [] = True+eqValList (val1:vals1) (val2:vals2) =+  if eqVal val1 val2+    then eqValList vals1 vals2+    else False+eqValList _ _ = False  eqVal :: EgisonVal -> EgisonVal -> Bool eqVal a b = do
lib/core/number.egi view
@@ -1,13 +1,13 @@ (define $Integer   (type     {[$var-match (lambda [$tgt] {tgt})]-     [$= (lambda [$val $tgt] (eq? val tgt))]}))+     [$= (lambda [$val $tgt] (eq-n? val tgt))]}))  (define $compare-integer   (lambda [$m $n]-    (if (lt? m n)+    (if (lt-n? m n)         <less>-        (if (eq? m n)+        (if (eq-n? m n)             <equal>             <greater>)))) @@ -36,7 +36,7 @@           {[$tgt (match (compare-integer tgt 0) Order                    {[<greater> {(- tgt 1)}]                     [_ {}]})]}]})]-     [$= (lambda [$val $tgt] (eq? val tgt))]}))+     [$= (lambda [$val $tgt] (eq-n? val tgt))]}))  (define $between   (lambda [$m $n]