{-# LANGUAGE TemplateHaskell #-}

module StringRewriting.Rule (
    Rule,
    rule,
    left,
    right,
    toPair,
    Rules,
    module StringRewriting.Generator,
  ) where

import StringRewriting.Generator

import Containers
import Lens

data Rule = R
  { Rule -> GWord
_left :: GWord
  , Rule -> GWord
_right :: GWord
  } deriving (Rule -> Rule -> Bool
(Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c== :: Rule -> Rule -> Bool
Eq, Eq Rule
Eq Rule
-> (Rule -> Rule -> Ordering)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Rule)
-> (Rule -> Rule -> Rule)
-> Ord Rule
Rule -> Rule -> Bool
Rule -> Rule -> Ordering
Rule -> Rule -> Rule
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Rule -> Rule -> Rule
$cmin :: Rule -> Rule -> Rule
max :: Rule -> Rule -> Rule
$cmax :: Rule -> Rule -> Rule
>= :: Rule -> Rule -> Bool
$c>= :: Rule -> Rule -> Bool
> :: Rule -> Rule -> Bool
$c> :: Rule -> Rule -> Bool
<= :: Rule -> Rule -> Bool
$c<= :: Rule -> Rule -> Bool
< :: Rule -> Rule -> Bool
$c< :: Rule -> Rule -> Bool
compare :: Rule -> Rule -> Ordering
$ccompare :: Rule -> Rule -> Ordering
$cp1Ord :: Eq Rule
Ord)

rule :: GWord -> GWord -> Rule
rule :: GWord -> GWord -> Rule
rule = GWord -> GWord -> Rule
R

makeLenses ''Rule

toPair :: Rule -> (GWord, GWord)
toPair :: Rule -> (GWord, GWord)
toPair (R GWord
l GWord
r) = (GWord
l, GWord
r)

type Rules = Set Rule