hw-balancedparens-0.4.1.3: Balanced parentheses
Safe HaskellSafe-Inferred
LanguageHaskell2010

HaskellWorks.Data.BalancedParens.FindClose

Documentation

class FindClose v where Source #

Methods

findClose :: v -> Count -> Maybe Count Source #

Find the closing parenthesis that machines the open parenthesis at the current position.

If the parenthesis at the current position is an close parenthesis, then return the current position.

Indexes are 1-based. 1 corresponds to open and 0 corresponds to close.

If we run out of bits in the supplied bit-string, the implementation my either return Nothing, or assume all the bits that follow are zeros.

>>> :set -XTypeApplications
>>> import Data.Maybe
>>> import HaskellWorks.Data.Bits.BitRead
>>> findClose (fromJust (bitRead @Word64 "00000000")) 1
Just 1
>>> findClose (fromJust (bitRead @Word64 "10101010")) 1
Just 2
>>> findClose (fromJust (bitRead @Word64 "10101010")) 2
Just 2
>>> findClose (fromJust (bitRead @Word64 "10101010")) 3
Just 4
>>> findClose (fromJust (bitRead @Word64 "11010010")) 1
Just 6
>>> findClose (fromJust (bitRead @Word64 "11110000")) 1
Just 8

Instances

Instances details
FindClose Word16 Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose Word32 Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose Word64 Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose Word8 Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

(BitLength a, CloseAt a, NewCloseAt a, FindCloseN a) => FindClose (RangeMin a) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.RangeMin

(BitLength a, NewCloseAt a, CloseAt a, FindCloseN a) => FindClose (RangeMin2 a) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.RangeMin2

FindClose a => FindClose (SimpleBalancedParens a) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.Simple

FindClose a => FindClose (BitShown a) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Broadword Word64) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Naive Word64) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Naive (Vector Word16)) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Naive (Vector Word32)) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Naive (Vector Word64)) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Naive (Vector Word8)) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Vector Word16) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Vector Word32) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Vector Word64) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose (Vector Word8) Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

FindClose [Bool] Source # 
Instance details

Defined in HaskellWorks.Data.BalancedParens.FindClose

Methods

findClose :: [Bool] -> Count -> Maybe Count Source #