Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
class FindClose v where Source #
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
FindClose Word16 Source # | |
FindClose Word32 Source # | |
FindClose Word64 Source # | |
FindClose Word8 Source # | |
(BitLength a, CloseAt a, NewCloseAt a, FindCloseN a) => FindClose (RangeMin a) Source # | |
(BitLength a, NewCloseAt a, CloseAt a, FindCloseN a) => FindClose (RangeMin2 a) Source # | |
FindClose a => FindClose (SimpleBalancedParens a) Source # | |
Defined in HaskellWorks.Data.BalancedParens.Simple | |
FindClose a => FindClose (BitShown a) Source # | |
FindClose (Broadword Word64) Source # | |
FindClose (Naive Word64) Source # | |
FindClose (Naive (Vector Word16)) Source # | |
FindClose (Naive (Vector Word32)) Source # | |
FindClose (Naive (Vector Word64)) Source # | |
FindClose (Naive (Vector Word8)) Source # | |
FindClose (Vector Word16) Source # | |
FindClose (Vector Word32) Source # | |
FindClose (Vector Word64) Source # | |
FindClose (Vector Word8) Source # | |
FindClose [Bool] Source # | |