egison 3.2.1 → 3.2.2
raw patch · 5 files changed
+30/−48 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Language.Egison.Primitives: primitiveEnvNoIO :: IO Env
Files
- egison.cabal +4/−6
- hs-src/Interpreter/egisoni.hs +5/−2
- hs-src/Language/Egison/Primitives.hs +9/−1
- lib/graph/graph.egi +0/−30
- lib/tree/tree.egi +12/−9
egison.cabal view
@@ -1,7 +1,7 @@ Name: egison-Version: 3.2.1-Synopsis: The world's first language with non-linear pattern-matching against unfree data-Description: An interpreter for Egison, the world's first programming langugage which realized non-linear pattern-matching with unfree data types.+Version: 3.2.2+Synopsis: The programming language with non-linear pattern-matching against unfree data+Description: An interpreter for Egison, the programming langugage that realized non-linear pattern-matching with unfree data types. With Egison, you can represent pattern-matching with unfree data types intuitively, especially for collection data, such as lists, multisets, sets. You can find Egison programs in "lib/" and "sample/" directories.@@ -18,7 +18,7 @@ Extra-Source-Files: benchmark/Benchmark.hs Data-files: lib/core/base.egi lib/core/number.egi lib/core/collection.egi- lib/graph/graph.egi lib/tree/tree.egi lib/tree/xml.egi lib/math/prime.egi+ lib/tree/tree.egi lib/tree/xml.egi lib/math/prime.egi elisp/egison-mode.el Library@@ -29,8 +29,6 @@ Language.Egison.Core Language.Egison.Desugar Language.Egison.Types- --Language.Egison.Variables- --Language.Egison.Numerical Language.Egison.Parser Language.Egison.Primitives Other-modules: Paths_egison
hs-src/Interpreter/egisoni.hs view
@@ -24,15 +24,18 @@ Options {optShowHelp = True} -> printHelp Options {optShowVersion = True} -> printVersionNumber Options {optPrompt = prompt, optShowBanner = bannerFlag} -> do- env <- primitiveEnv >>= loadLibraries case nonOpts of- [] -> when bannerFlag showBanner >> repl env prompt >> when bannerFlag showByebyeMessage+ [] -> do+ env <- primitiveEnv >>= loadLibraries+ when bannerFlag showBanner >> repl env prompt >> when bannerFlag showByebyeMessage (file:args) -> do case opts of Options {optLoadOnly = True} -> do+ env <- primitiveEnvNoIO >>= loadLibraries result <- evalEgisonTopExprs env [LoadFile file] either print (const $ return ()) result Options {optLoadOnly = False} -> do+ env <- primitiveEnv >>= loadLibraries result <- evalEgisonTopExprs env [LoadFile file, Execute args] either print (const $ return ()) result
hs-src/Language/Egison/Primitives.hs view
@@ -1,5 +1,5 @@ {-# Language FlexibleContexts #-}-module Language.Egison.Primitives (primitiveEnv) where+module Language.Egison.Primitives (primitiveEnv, primitiveEnvNoIO) where import Control.Arrow import Control.Applicative@@ -23,6 +23,14 @@ primitiveEnv :: IO Env primitiveEnv = do let ops = map (second PrimitiveFunc) (primitives ++ ioPrimitives)+ bindings <- forM (constants ++ ops) $ \(name, op) -> do+ ref <- newIORef . WHNF $ Value op+ return (name, ref)+ return $ extendEnv nullEnv bindings++primitiveEnvNoIO :: IO Env+primitiveEnvNoIO = do+ let ops = map (second PrimitiveFunc) primitives bindings <- forM (constants ++ ops) $ \(name, op) -> do ref <- newIORef . WHNF $ Value op return (name, ref)
− lib/graph/graph.egi
@@ -1,30 +0,0 @@-;;;-;;; graph.egi-;;;--(define $graph- (lambda [$a]- (multiset (nodeInfo a))))--(define $nodeInfo- (lambda [$a]- (algebraic-data-matcher- {<node a (multiset a) (multiset a)>})))--(define $hamilton-cycle- (pattern-function [$a]- <cons <node (& a_1 $h_1) <cons (& a_2 $h_2) _> _>- (loop $i [3 $n]- <cons <node ,h_(- i 1) <cons (& a_i $h_i) _> _>- ...>- <cons <node ,h_n <cons ,h_1 _> _>- <nil>>)>))--(define $hamilton-path- (pattern-function [$a]- <cons <node (& a_1 $h_1) <cons (& a_2 $h_2) _> _>- (loop $i [3 $n]- <cons <node ,h_(- i 1) <cons (& a_i $h_i) _> _>- ...>- <cons <node ,h_n _ _>- <nil>>)>))
lib/tree/tree.egi view
@@ -1,23 +1,26 @@ (define $b-tree- (lambda [$a]+ (lambda [$a $b] (algebraic-data-matcher- {<leaf a> <node (b-tree a) (b-tree a)>})))+ {<leaf b> <node (b-tree a b) (b-tree a b)>}))) -(define $n-tree- (lambda [$a]+(define $tree+ (lambda [$a $b] (matcher {[,$val []- {[$tgt (match [val tgt] [(n-tree a) (n-tree a)]+ {[$tgt (match [val tgt] [(tree a b) (tree a b)] {[[<lnode $x $ts> <lnode ,x ,ts>] {[]}] [[_ _] {}]})]}]- [<lnode $ $> [a (list (n-tree a))] ; Node whose children are seen as a list.+ [<leaf $> b+ {[<Leaf $x> {x}]+ [_ {}]}]+ [<lnode $ $> [a (list (tree a b))] ; Node whose children are seen as a list. {[<Node $x $ts> {[x ts]}] [_ {}]}]- [<mnode $ $> [a (multiset (n-tree a))] ; Node whose children are seen as a multiset.+ [<mnode $ $> [a (multiset (tree a b))] ; Node whose children are seen as a multiset. {[<Node $x $ts> {[x ts]}] [_ {}]}]- [<descendant $> [(n-tree a)]- {[$t {t @(match-all t (n-tree a)+ [<descendant $> [(tree a b)]+ {[$t {t @(match-all t (tree a b) [<mnode _ <cons <descendant $x> _>> x])}]}] [$ [something] {[$tgt {tgt}]}]