sweet-egison alternatives and similar packages
Based on the "Control" category.
Alternatively, view sweet-egison alternatives based on common mentions on social networks and blogs.
rio-orphans9.9 3.7 sweet-egison VS rio-orphansA standard library for Haskell
machines9.8 3.7 sweet-egison VS machinesNetworks of composable stream transducers
funflow9.8 0.0 sweet-egison VS funflowFunctional workflows
mtl9.8 5.8 sweet-egison VS mtlThe Monad Transformer Library
fused-effects9.8 7.0 sweet-egison VS fused-effectsA fast, flexible, fused effect system for Haskell
pipes9.8 2.1 sweet-egison VS pipesCompositional pipelines
transient9.8 0.0 sweet-egison VS transientA full stack, reactive architecture for general purpose programming. Algebraic and monadically composable primitives for concurrency, parallelism, event handling, transactions, multithreading, Web, and distributed computing with complete de-inversion of control (No callbacks, no blocking, pure state)
capability9.7 3.5 sweet-egison VS capabilityExtensional capabilities and deriving combinators
recursion-schemesGeneralized bananas, lenses and barbed wire
apecs9.7 0.0 sweet-egison VS apecsa fast, extensible, type driven Haskell ECS framework for games
distributed-closureSerializable closures for distributed programming.
freer-simple9.6 0.0 sweet-egison VS freer-simpleA friendly effect system for Haskell
record9.6 0.0 sweet-egison VS recordAnonymous records
free9.6 4.2 sweet-egison VS freefree monads
foldl9.6 0.0 sweet-egison VS foldlComposable, streaming, and efficient left folds
extensible-effectsExtensible Effects: An Alternative to Monad Transformers
classy-prelude9.5 0.0 sweet-egison VS classy-preludeType classes for mapping, folding, and traversing monomorphic containers
auto9.5 0.0 sweet-egison VS autoHaskell DSL and platform providing denotational, compositional api for discrete-step, locally stateful, interactive programs, games & automations. http://hackage.haskell.org/package/auto
selective9.5 1.6 sweet-egison VS selectiveSelective Applicative Functors: Declare Your Effects Statically, Select Which to Execute Dynamically
unliftio9.5 2.8 sweet-egison VS unliftioThe MonadUnliftIO typeclass for unlifting monads to IO
classy-prelude-yesodType classes for mapping, folding, and traversing monomorphic containers
safe-exceptions9.5 0.0 sweet-egison VS safe-exceptionsSafe, consistent, and easy exception handling
abstract-par9.4 1.0 sweet-egison VS abstract-parType classes generalizing the functionality of the 'monad-par' library.
these9.4 1.0 sweet-egison VS theseAn either-or-both data type, with corresponding hybrid error/writer monad transformer.
hask9.4 0.0 sweet-egison VS haskCategory theory for Haskell with a lens flavor (you need GHC 7.8.3, not 7.8.2 to build this!)
ComonadSheet9.4 0.0 sweet-egison VS ComonadSheetA library for expressing "spreadsheet-like" computations with absolute and relative references, using fixed-points of n-dimensional comonads.
retry9.4 0.0 sweet-egison VS retryRetry combinators for monadic actions that may fail
frpnow9.3 0.0 sweet-egison VS frpnowPrincipled practical FRP
parallel9.3 2.0 sweet-egison VS parallela library for parallel programming
transient-universeA Cloud monad based on transient for the creation of Web and reactive distributed applications that are fully composable, where Web browsers are first class nodes in the cloud
cloud-haskell9.2 0.0 sweet-egison VS cloud-haskellThis is an umbrella development repository for Cloud Haskell
deepseq9.2 4.0 sweet-egison VS deepseqDeep evaluation of data structures
distributed-process-platformDEPRECATED (Cloud Haskell Platform) in favor of distributed-process-extras, distributed-process-async, distributed-process-client-server, distributed-process-registry, distributed-process-supervisor, distributed-process-task and distributed-process-execution
distributed-fork9.2 0.0 sweet-egison VS distributed-forkA distributed data processing framework in Haskell.
ifcxt9.1 0.0 sweet-egison VS ifcxtconstraint level if statements
tardis9.1 0.0 sweet-egison VS tardisBidirectional state monad transformer
monad-validate9.1 0.0 sweet-egison VS monad-validate(NOTE: REPOSITORY MOVED TO NEW OWNER: https://github.com/lexi-lambda/monad-validate) A Haskell monad transformer library for data validation
either9.1 0.0 sweet-egison VS eitherthe EitherT monad transformer
contravariant9.1 1.6 sweet-egison VS contravariantHaskell 98 contravariant functors
monad-control9.1 0.0 sweet-egison VS monad-controlLift control operations, like exception catching, through monad transformers
ixmonad9.0 0.0 sweet-egison VS ixmonadProvides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects.
errors9.0 0.0 sweet-egison VS errorsType-safe error handling
effect-monad9.0 0.0 sweet-egison VS effect-monadProvides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects.
freer-effects9.0 0.0 sweet-egison VS freer-effectsAn implementation of "Freer Monads, More Extensible Effects".
operational9.0 0.0 sweet-egison VS operationalImplement monads by specifying instructions and their desired operational semantics.
objective8.9 2.9 sweet-egison VS objectivePurely functional objects
motor8.9 0.0 sweet-egison VS motorType-safe effectful state machines in Haskell
exceptions8.9 0.0 sweet-egison VS exceptionsmtl friendly exceptions
monad-time8.9 0.0 sweet-egison VS monad-timeType class for monads which carry the notion of the current time.
mmorph8.9 0.0 sweet-egison VS mmorphMonad morphisms
Static code analysis for 29 languages.
Do you think we are missing an alternative of sweet-egison or a related project?
The Sweet Egison is a shallow embedding implementation of non-linear pattern matching with extensible and polymorphic patterns . This library desguars the [Egison](https:///www.egison.org) pattern-match expressions into Haskell programs that use non-deterministic monads. This library provides a base of the pattern-match-oriented (PMO) programming style  for Haskell users at a practical level of efficiency.
We code the equivalent pattern match of
case [1, 2, 3] of x : xs -> (x, xs) in this library as follows:
> matchAll dfs [1, 2, 3] (List Something) [[mc| $x : $xs -> (x, xs) |]] [(1,[2,3])]
Here, we can only observe the small syntactic difference in pattern expressions: the variable bindings are prefixed with
$. (We'll come back to
List Something later.)
You may notice that
matchAll returns a list.
In our library, pattern matching can return many results.
See the following example that doubles all elements in a list:
> take 10 $ matchAll dfs [1 ..] (List Something) [[mc| _ ++ $x : _ -> x * 2 |]] [2,4,6,8,10,12,14,16,18,20]
++ is the join operator that decomposes a list into an initial prefix and the remaining suffix.
We can implement
map with pattern matching using this:
> map f xs = matchAll dfs xs (List Something) [[mc| _ ++ $x : _ -> f x |]] > map (*2) [1,2,3] [2,4,6]
Note that we don't see any recursions or
folds in our
map definition! An intuition of
map function, that applies the function to all elements, are expressed directly in the pattern expression.
Because our pattern matching can return many results, we can use it to decompose non-free data types such as multisets and sets. For example:
> matchAll dfs [1, 2, 3] (Multiset Something) [[mc| $x : $xs -> (x, xs) |]] [(1,[2,3]),(2,[1,3]),(3,[1,2])]
Multiset Something instead of
List Something here to match the target
[1, 2, 3] as a multiset.
These parameters such as
List (List Something), and
Something are called matchers and specify pattern-matching methods.
Given a matcher
Multiset m is a matcher for multisets that matches its elements with
Something is a matcher that provides simple matching methods for an arbitrary value.
Pattern constructors such as
++ are overloaded over matchers for collections to archive the ad-hoc polymorphism of patterns.
Controlling matching strategy
Some pattern matching have infinitely many results and
matchAll bfs is designed to be able to enumerate all the results.
For this purpose,
matchAll bfs traverses a search tree for pattern matching in the breadth-first order.
The following example illustrates this:
> take 10 $ matchAll bfs [1 ..] (Set Something) [[mc| $x : $y : _ -> (x, y) |]] [(1,1),(2,1),(1,2),(3,1),(1,3),(2,2),(1,4),(4,1),(1,5),(2,3)]
We can use the depth-first search with
> take 10 $ matchAll dfs [1 ..] (Set Something) [[mc| $x : $y : _ -> (x, y) |]] [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10)]
In most cases, the depth-first search is faster than the default breadth-first search strategy.
It is recommended to always use
matchAll dfs if it is OK to do so.
matchAll dfs, we can define an intuitive pattern-matching version of
concat function on lists.
> concat xs = matchAll dfs xs (List (List Something)) [[mc| _ ++ (_ ++ $x : _) : _ -> x |]] > concat [[1,2], [3,4,5]] [1,2,3,4,5]
The non-linear pattern is another powerful pattern-matching feature.
It allows us to refer the value bound to variables appear in the left side of the pattern.
We provide a pattern syntax named value patterns in the form of
Eql matcher enables value patterns to match with targets that are equal to the corresponding expression.
For example, the following example enumerates (p, p+2) pairs of primes:
> import Data.Numbers.Primes ( primes ) > take 10 $ matchAll bfs primes (List Eql) [[mc| _ ++ $p : #(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 implement a pattern-matching version of set functions such as
intersect in a declarative way using non-linear patterns.
Match clauses are monoids and can be concatenated using
> member x xs = match dfs xs (Multiset Eql) [[mc| #x : _ -> True |], [mc| _ -> False |]] > member 1 [3,4,1,4] True > intersect xs ys = matchAll dfs (xs, ys) (Pair (Set Eql) (Set Eql)) [[mc| ($x : _, #x : _) -> x |]] > intersect [1,2,3] [4,5,3,2] [2,3]
Some practical applications of PMO such as a SAT solver are placed under example/. Detailed information of Egison, the original PMO language implementation, can be found on https://www.egison.org/ or in . You can learn more about pattern-match-oriented programming style in .
Sweet Egison transform patterns into a program that uses non-deterministic monads.
mc translates match clauses into functions that take a target and return a non-deterministic computation as
MonadPlus-like monadic expression.
MonadPlus can express backtracking computation, we can perform efficient backtracking pattern matching.
For example, the match clause
[mc| $x : #(x + 10) : _ -> (x, x + 10) |] is transformed as follows:
\ (mat_a5sV, tgt_a5sW) -> let (tmpM_a5sX, tmpM_a5sY) = (consM mat_a5sV) tgt_a5sW in ((fromList (((cons (GP, GP)) mat_a5sV) tgt_a5sW)) >>= (\ (tmpT_a5sZ, tmpT_a5t0) -> let x = tmpT_a5sZ in let (tmpM_a5t1, tmpM_a5t2) = (consM tmpM_a5sY) tmpT_a5t0 in ((fromList (((cons (GP, WC)) tmpM_a5sY) tmpT_a5t0)) >>= (\ (tmpT_a5t3, tmpT_a5t4) -> ((fromList ((((value (x + 10)) ()) tmpM_a5t1) tmpT_a5t3)) >>= (\ () -> pure (x, x + 10)))))))
The infix operators
++ are synonyms of
join, respectively, and desugared in that way during translation.
matchAll function is defined as a function that creates and passes the argument for this non-deterministic monads.
matchAll strategy target matcher = concatMap (\b -> toList (strategy (matcher, target) >>= b))
Consequently, the pattern-match expression
matchAll dfs [1, 2, 3, 12] (Multiset Eql) [[mc| $x : #(x + 10) : _ -> (x, x + 10) |]] -- [(2, 12)]
is transformed into a program that is equivalent to the following:
concatMap (\b -> toList (dfs (Multiset Eql, [1, 2, 3, 12]) >>= b)) [\ (mat_a5sV, tgt_a5sW) -> let (tmpM_a5sX, tmpM_a5sY) = (consM mat_a5sV) tgt_a5sW in ((fromList (((cons (GP, GP)) mat_a5sV) tgt_a5sW)) >>= (\ (tmpT_a5sZ, tmpT_a5t0) -> let x = tmpT_a5sZ in let (tmpM_a5t1, tmpM_a5t2) = (consM tmpM_a5sY) tmpT_a5t0 in ((fromList (((cons (GP, WC)) tmpM_a5sY) tmpT_a5t0)) >>= (\ (tmpT_a5t3, tmpT_a5t4) -> ((fromList ((((value (x + 10)) ()) tmpM_a5t1) tmpT_a5t3)) >>= (\ () -> pure (x, x + 10)))))))]
MiniEgison (Deep Embedding) vs. Sweet Egison (Shallow Embedding)
miniEgison is also a Haskell library that implements Egison pattern matching. The main difference between miniEgison and Sweet Egison is that Sweet Egison translates pattern matching into Haskell control expressions (shallow embedding), whereas miniEgison translates it into Haskell data expressions (deep embedding). As a result, Sweet Egison is faster than miniEgison. The following benchmark is taken using MacBook Pro (2017, 2.3 GHz Intel Core i5).
|comb2 (n = 15000)||perm2 (n = 5000)||CDCL (50 vars)|
|miniEgison||13.029 sec||3.854 sec||1.025 sec|
|Sweet Egison||0.303 sec||0.462 sec||0.097 sec|
There is almost no execution performance differences between programs written using list comprehensions and Sweet Egison.
|comb2 (n = 15000)||comb2 (n = 15000)||perm2 (n = 5000)||perm2 (n = 10000)|
|List Comprehensions||0.347 sec||1.244 sec||0.409 sec||2.077 sec|
|Sweet Egison||0.309 sec||1.081 sec||0.434 sec||1.984 sec|
Programs used for the above benchmarks are follows:
-  Satoshi Egi and Yuichi Nishiwaki: Functional Programming in Pattern-Match-Oriented Programming Style, The Art, Science, and Engineering of Programming, 2020, Vol. 4, Issue 3, Article 7, DOI: 10.22152/programming-journal.org/2020/4/7
-  Satoshi Egi and Yuichi Nishiwaki: Non-linear Pattern Matching with Backtracking for Non-free Data Types, APLAS 2018 - Asian Symposium on Programming Languages and Systems, DOI: 11.1007/978-3-030-02768-1_1