pcre-less-0.2.0: Text/Regex/Less/Quackers.hs
{- copyright (c) sreservoir.
license bsd three-clause. -}
{-# LANGUAGE FlexibleInstances,TypeSynonymInstances #-}
module Text.Regex.Less.Quackers (QLR(..)) where
import qualified Text.Regex.PCRE as R
import Text.Regex.Less.REOpts
-- the QLR (QuacksLikeRegex) class:
-- compile
-- instances of QLR:
-- String
-- (String,[RECtOpts])
-- (String,[RERtOpts])
-- (String,([RECtOpts],[RERtOpts]))
-- (String,([RERtOpts],[RECtOpts]))
-- ((String,[RECtOpts]),[RERtOpts])
-- ((String,[RERtOpts]),[RECtOpts])
-- QuacksLikeRegex: can =~ .
class QLR a where
compile :: a -> R.Regex
instance QLR String where
compile a = R.makeRegexOpts (reCtOpts []) (reRtOpts []) a
instance QLR (String,[RECtOpts]) where
compile (a,b) = R.makeRegexOpts (reCtOpts b) (reRtOpts []) a
instance QLR (String,[RERtOpts]) where
compile (a,b) = R.makeRegexOpts (reCtOpts []) (reRtOpts b) a
instance QLR ((String,[RECtOpts]),[RERtOpts]) where
compile ((a,b),c) = R.makeRegexOpts (reCtOpts b) (reRtOpts c) a
instance QLR ((String,[RERtOpts]),[RECtOpts]) where
compile ((a,b),c) = R.makeRegexOpts (reCtOpts c) (reRtOpts b) a
instance QLR (String,([RECtOpts],[RERtOpts])) where
compile (a,(b,c)) = R.makeRegexOpts (reCtOpts b) (reRtOpts c) a
instance QLR (String,([RERtOpts],[RECtOpts])) where
compile (a,(b,c)) = R.makeRegexOpts (reCtOpts c) (reRtOpts b) a