packages feed

mini-egison-0.1.0: mini-egison.cabal

cabal-version: 1.12

name:           mini-egison
version:        0.1.0
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
author:         Mayuko Kori, Satoshi Egi
maintainer:     Satoshi Egi <egi@egison.org>
license:        MIT
license-file:   LICENSE
category:       Data, Pattern
build-type:     Simple
extra-source-files:
    README.md
    ChangeLog.md

source-repository head
  type: git
  location: https://github.com/egison/egison-haskell

library
  exposed-modules:
      Control.Egison
      Control.Egison.Core
      Control.Egison.Match
      Control.Egison.Matcher
      Control.Egison.QQ
  other-modules:
      Paths_mini_egison
  hs-source-dirs:
      src
  build-depends:
      base >=4.7 && <5
    , containers
    , split
    , haskell-src-meta
    , regex-compat
    , template-haskell
  default-language: Haskell2010

test-suite mini-egison-test
  type: exitcode-stdio-1.0
  main-is: Test.hs
  other-modules:
      Spec
      Paths_mini_egison
  hs-source-dirs:
      test
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , mini-egison
    , hspec
    , primes
  default-language: Haskell2010