Popularity
6.6
Stable
Activity
0.0
Stable
12
4
4
Monthly Downloads: 10
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags:
Control
Latest version: v0.6.1
rex alternatives and similar packages
Based on the "Control" category.
Alternatively, view rex alternatives based on common mentions on social networks and blogs.
-
transient
A 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) -
distributed-closure
Serializable closures for distributed programming. -
selective
Selective Applicative Functors: Declare Your Effects Statically, Select Which to Execute Dynamically -
classy-prelude-yesod
Type classes for mapping, folding, and traversing monomorphic containers -
auto
Haskell DSL and platform providing denotational, compositional api for discrete-step, locally stateful, interactive programs, games & automations. http://hackage.haskell.org/package/auto -
hask
Category theory for Haskell with a lens flavor (you need GHC 7.8.3, not 7.8.2 to build this!) -
extensible-effects
Extensible Effects: An Alternative to Monad Transformers -
classy-prelude
Type classes for mapping, folding, and traversing monomorphic containers -
ComonadSheet
A library for expressing "spreadsheet-like" computations with absolute and relative references, using fixed-points of n-dimensional comonads. -
transient-universe
A 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 -
abstract-par
Type classes generalizing the functionality of the 'monad-par' library. -
these
An either-or-both data type, with corresponding hybrid error/writer monad transformer. -
distributed-fork
A distributed data processing framework in Haskell. -
cloud-haskell
This is an umbrella development repository for Cloud Haskell -
distributed-process-platform
DEPRECATED (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 -
monad-validate
A Haskell monad transformer library for data validation -
monad-control
Lift control operations, like exception catching, through monad transformers -
monad-time
Type class for monads which carry the notion of the current time. -
operational
Implement monads by specifying instructions and their desired operational semantics. -
ixmonad
Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects. -
effect-monad
Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects. -
freer-effects
An implementation of "Freer Monads, More Extensible Effects".
Static code analysis for 29 languages.
Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.
Promo
www.sonarqube.org
Do you think we are missing an alternative of rex or a related project?
README
http://hackage.haskell.org/package/rex
Provides a quasi-quoter for regular expressions which yields a tuple, of appropriate arity and types, representing the results of the captures. Allows the user to specify parsers for captures as inline Haskell. Can also be used to provide typeful pattern matching in function definitions and case patterns.
To build / install:
./Setup.hs configure --user
./Setup.hs build
./Setup.hs install
See the haddock or Text/Regex/PCRE/Rex.hs
for documentation.
Some examples (verbatim from Test.hs):
math x = mathl x 0
mathl [] x = x
mathl [rex|^ \s*(?{ read -> y }\d+)\s*(?{ s }.*)$|] x = mathl s y
mathl [rex|^\+\s*(?{ read -> y }\d+)\s*(?{ s }.*)$|] x = mathl s $ x + y
mathl [rex|^ -\s*(?{ read -> y }\d+)\s*(?{ s }.*)$|] x = mathl s $ x - y
mathl [rex|^\*\s*(?{ read -> y }\d+)\s*(?{ s }.*)$|] x = mathl s $ x * y
mathl [rex|^ /\s*(?{ read -> y }\d+)\s*(?{ s }.*)$|] x = mathl s $ x / y
mathl str x = error str
-- math "1 + 3" == 4.0
-- math "3 * 2 + 100" == 106.0
-- math "20 / 3 + 100 * 2" == 213.33333333333334
peano :: String -> Maybe Int
peano = [rex|^(?{ length . filter (=='S') } \s* (?:S\s+)*Z)\s*$|]
-- peano "S Z" == Just 1
-- peano "S S S S Z" == Just 4
-- peano "S S Z" == Just 2
parsePair :: String -> Maybe (String, String)
parsePair = [rex|^<\s* (?{ }[^\s,>]+) \s*,\s* (?{ }[^\s,>]+) \s*>$|]
-- parsePair "<-1, 3>" == Just ("-1","3")
-- parsePair "<-4,3b0>" == Just ("-4","3b0")
-- parsePair "< a, -30 >" == Just ("a","-30")
-- parsePair "< a, other>" == Just ("a","other")
-- From http://www.regular-expressions.info/dates.html
parseDate :: String -> Maybe (Int, Int, Int)
parseDate [rex|^(?{ read -> y }(?:19|20)\d\d)[- /.]
(?{ read -> m }0[1-9]|1[012])[- /.]
(?{ read -> d }0[1-9]|[12][0-9]|3[01])$|]
| (d > 30 && (m `elem` [4, 6, 9, 11]))
|| (m == 2 &&
(d ==29 && not (mod y 4 == 0 && (mod y 100 /= 0 || mod y 400 == 0)))
|| (d > 29)) = Nothing
| otherwise = Just (y, m, d)
parseDate _ = Nothing
-- parseDate "1993.8.10" == Nothing
-- parseDate "1993.08.10" == Just (1993,8,10)
-- parseDate "2003.02.28" == Just (2003,2,28)
-- parseDate "2003.02.27" == Just (2003,2,27)
onNull a f [] = a
onNull _ f xs = f xs
nonNull = onNull Nothing
disjunct [rex| ^(?:(?{nonNull $ Just . head -> a} .)
| (?{nonNull $ Just . head -> b} ..)
| (?{nonNull $ Just . last -> c} ...))$|] =
head $ catMaybes [a, b, c]
-- disjunct "a" == 'a'
-- disjunct "ab" == 'a'
-- disjunct "abc" == 'c'