mini-egison 0.1.5 → 0.1.6
raw patch · 3 files changed
+20/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +1/−0
- mini-egison.cabal +1/−1
- test/Spec.hs +18/−2
README.md view
@@ -1,4 +1,5 @@ # miniEgison: Template Haskell Implementation of Egison Pattern Matching+[](https://travis-ci.org/egison/egison-haskell) This Haskell library provides the users with the pattern-matching facility against non-free data types. Non-free data types are data types whose data have no standard forms.
mini-egison.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12 name: mini-egison-version: 0.1.5+version: 0.1.6 synopsis: Template Haskell Implementation of Egison Pattern Matching description: This package provides the pattern-matching facility that fulfills the following three criteria for practical pattern matching for non-free data types\: (i) non-linear pattern matching with backtracking; (ii) extensibility of pattern-matching algorithms; (iii) ad-hoc polymorphism of patterns. Non-free data types are data types whose data have no standard forms.
test/Spec.hs view
@@ -16,6 +16,18 @@ pmConcat xss = matchAll xss (Multiset (Multiset Something)) [[mc| cons (cons $x _) _ => x |]] +pmUniq :: (Eq a) => [a] -> [a]+pmUniq xs = matchAll xs (List Eql)+ [[mc| join _ (cons $x (not (join _ (cons #x _)))) => x |]]++pmIntersect :: (Eq a) => [a] -> [a] -> [a]+pmIntersect xs ys = matchAll (xs, ys) (Pair (Multiset Eql) (Multiset Eql))+ [[mc| pair (cons $x _) (cons #x _) => x |]]++pmDiff :: (Eq a) => [a] -> [a] -> [a]+pmDiff xs ys = matchAll (xs, ys) (Pair (Multiset Eql) (Multiset Eql))+ [[mc| pair (cons $x _) (not (cons #x _)) => x |]]+ spec :: Spec spec = do describe "list and multiset matchers" $ do@@ -98,5 +110,9 @@ pmap (+ 10) [1,2,3] `shouldBe` [11, 12, 13] it "concat" $ pmConcat [[1,2], [3], [4, 5]] `shouldBe` [1..5]- -- it "uniq" $- -- pmUniq [1,1,2,3,2] `shouldBe` [1,2,3]+ it "uniq" $+ pmUniq [1,1,2,3,2] `shouldBe` [1,3,2]+ it "intersect" $+ pmIntersect [1,2,3,4] [2,4,5] `shouldBe` [2,4]+ it "diff" $+ pmDiff [1,2,3,4] [2,4,5] `shouldBe` [1,3]