regex-type-0.1.0.0: Type-level regular expressions

Copyright(C) 2016 Csongor Kiss
LicenseBSD3
MaintainerCsongor Kiss <kiss.csongor.kiss@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell2010

Data.Type.Regex

Contents

Description

Match Haskell types with regular expressions using nondeterministic finite automata constructed at the type level.

Synopsis

Matching

class input ~= re Source

The constraint is satisfied when the input matches the given regular expression re.

example :: ('[a] ~= (Int :| Char)) => a -> a
example = id

The functon example can only satisfy the types `Int -> Int' and `Char -> Char`'.

Combinators

type (:|) a b = Alt (ToTerm a) (ToTerm b) Source

Analogous to the regular expression (a | b)

type (:>) a b = Seq (ToTerm a) (ToTerm b) Source

Sequence regular expression terms. The traditional regular expression matched character-by-character, in that case, this sequencing would delimit character-rules. Here, we're matching types in a type-level list. (as opposed to characters in a list, aka String)

type Rep a = Rep (ToTerm a) Source

Analogous to the regular expression (a*)

type Opt a = Alt (ToTerm a) Null Source

Analogous to the regular expression (a?)

type Plus a = Seq (ToTerm a) (Rep (ToTerm a)) Source

Analogous to the regular expression (a+)