module StrBldr.String ( Str , Bldr , fromBuilder , toBuilder , splitAt , null , allMatches ) where import Data.Semigroup (Endo(Endo, appEndo)) import Text.Regex.PCRE.Heavy (Regex) import qualified Text.Regex.PCRE.Heavy as Pcre.H import Prelude hiding (splitAt, null) import qualified Prelude type Str = String -- Other obvious options for 'Bldr' here would be -- -- > type Bldr = String -- > -- > toBuilder = id -- > fromBuilder = id -- -- (in other words, don't bother at all with this builder strategy), and -- perhaps a better implementation of this difference list idea. type Bldr = Endo String toBuilder :: Str -> Bldr toBuilder str = Endo (str <>) fromBuilder :: Bldr -> Str fromBuilder bldr = appEndo bldr "" splitAt :: Int -> Str -> (Str, Str) splitAt = Prelude.splitAt null :: Str -> Bool null = Prelude.null allMatches :: Regex -> Str -> [((Int, Int), [(Int, Int)])] allMatches = Pcre.H.scanRanges