packages feed

egison 3.6.2 → 3.6.3

raw patch · 5 files changed

+36/−4 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Language.Egison.Types: UserIndexedData :: EgisonValue -> [UserIndex EgisonValue] -> EgisonValue
+ Language.Egison.Types: UserIndexedExpr :: EgisonExpr -> [UserIndex EgisonExpr] -> EgisonExpr
+ Language.Egison.Types: Userscript :: a -> UserIndex a
+ Language.Egison.Types: data UserIndex a
+ Language.Egison.Types: instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.Egison.Types.UserIndex a)
+ Language.Egison.Types: instance GHC.Show.Show (Language.Egison.Types.UserIndex Language.Egison.Types.EgisonExpr)
+ Language.Egison.Types: instance GHC.Show.Show (Language.Egison.Types.UserIndex Language.Egison.Types.EgisonValue)
+ Language.Egison.Types: instance GHC.Show.Show (Language.Egison.Types.UserIndex Language.Egison.Types.ScalarData)

Files

egison.cabal view
@@ -1,5 +1,5 @@ Name:                egison-Version:             3.6.2+Version:             3.6.3 Synopsis:            Programming language with non-linear pattern-matching against non-free data Description:   An interpreter for Egison, a **pattern-matching-oriented**, purely functional programming language.
hs-src/Language/Egison/Core.hs view
@@ -255,6 +255,14 @@       _ -> throwError $ TypeMismatch "integer or string" $ Value val   makeHashKey whnf = throwError $ TypeMismatch "integer or string" $ whnf +evalExpr env (UserIndexedExpr expr indices) = do+  val <- evalExprDeep env expr+  js <- mapM (\i -> case i of+                      Userscript n -> evalExprDeep env n >>= return . Userscript) indices+  case val of+    (UserIndexedData val' is') -> return $ Value $ UserIndexedData val' (is' ++ js)+    _ -> return $ Value $ UserIndexedData val js+ evalExpr env (IndexedExpr expr indices) = do   tensor <- case expr of               (VarExpr var) -> do@@ -712,6 +720,10 @@   mExprs <- mapM extractScalar args   return (Value (ScalarData (Div (Plus [(Term 1 [(Apply fn mExprs, 1)])]) (Plus [(Term 1 [])])))) applyFunc _ (Value fn@(ScalarData (Div (Plus [(Term 1 [(Symbol _ _ _, 1)])]) (Plus [(Term 1 [])])))) arg = do+  args <- tupleToList arg+  mExprs <- mapM extractScalar args+  return (Value (ScalarData (Div (Plus [(Term 1 [(Apply fn mExprs, 1)])]) (Plus [(Term 1 [])]))))+applyFunc _ (Value fn@(UserIndexedData _ _)) arg = do   args <- tupleToList arg   mExprs <- mapM extractScalar args   return (Value (ScalarData (Div (Plus [(Term 1 [(Apply fn mExprs, 1)])]) (Plus [(Term 1 [])]))))
hs-src/Language/Egison/Parser.hs view
@@ -156,8 +156,11 @@  expr :: Parser EgisonExpr expr = P.lexeme lexer (do expr0 <- expr'-                          expr1 <- option expr0 $ IndexedExpr expr0 <$> many1 (try (char '_' >> expr' >>= return . Subscript) <|> try (char '~' >> expr' >>= return . Superscript) <|> try (string "~_" >> expr' >>= return . SupSubscript))-                          option expr1 $ PowerExpr expr1 <$> (try $ char '^' >> expr'))+                          expr1 <- option expr0 $ IndexedExpr expr0 <$> many1 (try (char '_' >> expr' >>= return . Subscript)+                                                                           <|> try (char '~' >> expr' >>= return . Superscript)+                                                                           <|> try (string "~_" >> expr' >>= return . SupSubscript))+                          expr2 <- option expr1 $ UserIndexedExpr expr1 <$> many1 (try $ char '|' >> expr' >>= return . Userscript)+                          option expr2 $ PowerExpr expr1 <$> (try $ char '^' >> expr'))                             expr' :: Parser EgisonExpr
hs-src/Language/Egison/Types.hs view
@@ -17,6 +17,7 @@     , EgisonPattern (..)     , Arg (..)     , Index (..)+    , UserIndex (..)     , InnerExpr (..)     , BindingExpr (..)     , MatchClause (..)@@ -197,6 +198,7 @@   | VarExpr String   | FreshVarExpr   | IndexedExpr EgisonExpr [Index EgisonExpr]+  | UserIndexedExpr EgisonExpr [UserIndex EgisonExpr]   | PowerExpr EgisonExpr EgisonExpr   | InductiveDataExpr String [EgisonExpr]   | TupleExpr [EgisonExpr]@@ -271,6 +273,9 @@   | SupSubscript a  deriving (Eq) +data UserIndex a = Userscript a+ deriving (Eq)+ data InnerExpr =     ElementExpr EgisonExpr   | SubCollectionExpr EgisonExpr@@ -337,6 +342,7 @@   | Bool Bool   | ScalarData ScalarData   | TensorData (Tensor EgisonValue)+  | UserIndexedData EgisonValue [UserIndex EgisonValue]   | Float Double Double   | InductiveData String [EgisonValue]   | Tuple [EgisonValue]@@ -1009,6 +1015,7 @@     f j [] = ""     f j xs = "[| " ++ unwords (map show (take j xs)) ++ " |] " ++ f j (drop j xs)   show (TensorData (Tensor ns xs js)) = "(tensor {" ++ unwords (map show ns) ++ "} {" ++ unwords (map show (V.toList xs)) ++ "} )" ++ concat (map show js)+  show (UserIndexedData x js) = show x ++ concat (map show js)   show (Float x y) = showComplexFloat x y   show (InductiveData name []) = "<" ++ name ++ ">"   show (InductiveData name vals) = "<" ++ name ++ " " ++ unwords (map show vals) ++ ">"@@ -1104,6 +1111,7 @@  (CharHash vals) == (CharHash vals') = vals == vals'  (StrHash vals) == (StrHash vals') = vals == vals'  (PrimitiveFunc name1 _) == (PrimitiveFunc name2 _) = name1 == name2+ (UserIndexedData val is) == (UserIndexedData val' is') = (val == val') && (is == is')  -- Temporary: searching a better solution  (Func Nothing _ xs1 expr1) == (Func Nothing _ xs2 expr2) = (xs1 == xs2) && (expr1 == expr2)  (Func (Just name1) _ _ _) == (Func (Just name2) _ _ _) = name1 == name2@@ -1347,6 +1355,15 @@   show (Superscript i) = "~" ++ show i   show (Subscript i) = "_" ++ show i   show (SupSubscript i) = "~_" ++ show i++instance Show (UserIndex EgisonExpr) where+  show (Userscript i) = "|" ++ show i++instance Show (UserIndex ScalarData) where+  show (Userscript i) = "|" ++ show i++instance Show (UserIndex EgisonValue) where+  show (Userscript i) = "|" ++ show i  nullEnv :: Env nullEnv = Env []
lib/math/analysis/derivative.egi view
@@ -18,7 +18,7 @@        [(,sqrt $g) (* (/ 1 (* 2 (sqrt g))) (∂/∂ g x))]        [(,** $g $h) (* f (∂/∂ (* (log g) h) x))]        [<apply $g $args>-        (sum (map 2#(* (capply `(add-subscript g %1) args) (∂/∂ %2 x))+        (sum (map 2#(* (capply `g|%1 args) (∂/∂ %2 x))                   (zip nats args)))]        ; quote        [<quote $g> (∂/∂ g x)]