mini-egison 0.1.0 → 0.1.1
raw patch · 1 files changed
+1/−65 lines, 1 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- mini-egison.cabal +1/−65
mini-egison.cabal view
@@ -1,77 +1,13 @@ cabal-version: 1.12 name: mini-egison-version: 0.1.0+version: 0.1.1 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. For example, multisets are non-free data types because the multiset '[a,b,b]' has two other equivalent but literally different forms '[b,a,b]' and '[b,b,a]'. . The design of the pattern-matching facility is originally proposed in <https://arxiv.org/abs/1808.10603 this paper> and implemented in <http://github.com/egison/egison/ the Egison programming language>.- .- /Samples/- .- We can extract all twin primes from the list of prime numbers by pattern matching:- .- > take 10 (matchAll primes (List Integer)- > [[mc| join _ (cons $p (cons #(p+2) _)) => (p, p+2) |]])- > -- [(3,5),(5,7),(11,13),(17,19),(29,31),(41,43),(59,61),(71,73),(101,103),(107,109)]- .- We can describe patterns for each poker hand utilizing pattern matching for a multiset:- .- > poker cs =- > match cs (Multiset CardM)- > [[mc| cons (card $s $n)- > (cons (card #s #(n-1))- > (cons (card #s #(n-2))- > (cons (card #s #(n-3))- > (cons (card #s #(n-4))- > _)))) => "Straight flush" |],- > [mc| cons (card _ $n)- > (cons (card _ #n)- > (cons (card _ #n)- > (cons (card _ #n)- > (cons _- > _)))) => "Four of a kind" |],- > [mc| cons (card _ $m)- > (cons (card _ #m)- > (cons (card _ #m)- > (cons (card _ $n)- > (cons (card _ #n)- > _)))) => "Full house" |],- > [mc| cons (card $s _)- > (cons (card #s _)- > (cons (card #s _)- > (cons (card #s _)- > (cons (card #s _)- > _)))) => "Flush" |],- > [mc| cons (card _ $n)- > (cons (card _ #(n-1))- > (cons (card _ #(n-2))- > (cons (card _ #(n-3))- > (cons (card _ #(n-4))- > _)))) => "Straight" |],- > [mc| cons (card _ $n)- > (cons (card _ #n)- > (cons (card _ #n)- > (cons _- > (cons _- > _)))) => "Three of a kind" |],- > [mc| cons (card _ $m)- > (cons (card _ #m)- > (cons (card _ $n)- > (cons (card _ #n)- > (cons _- > _)))) => "Two pair" |],- > [mc| cons (card _ $n)- > (cons (card _ #n)- > (cons _- > (cons _- > (cons _- > _)))) => "One pair" |],- > [mc| _ => "Nothing" |]]- .- The pattern-matching algorithms for 'List' and 'Multiset' can be defined by users. homepage: https://github.com/egison/egison-haskell#readme bug-reports: https://github.com/egison/egison-haskell/issues