{-# LANGUAGE FlexibleInstances #-} module HaskellWorks.Data.BalancedParens.NewOpenAt ( NewOpenAt(..) ) where import Data.Word import HaskellWorks.Data.Bits.BitLength import HaskellWorks.Data.Bits.BitShown import HaskellWorks.Data.Bits.BitWise import HaskellWorks.Data.Positioning import qualified Data.Vector.Storable as DVS class NewOpenAt v where newOpenAt :: v -> Count -> Bool newOpenAt' :: (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' :: forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' a v Count c = (Count 0 forall a. Ord a => a -> a -> Bool <= Count c Bool -> Bool -> Bool && Count c forall a. Ord a => a -> a -> Bool < forall v. BitLength v => v -> Count bitLength a v) Bool -> Bool -> Bool && (a v forall a. TestBit a => a -> Position -> Bool .?. forall a. ToPosition a => a -> Position toPosition Count c) {-# INLINE newOpenAt' #-} instance (BitLength a, TestBit a) => NewOpenAt (BitShown a) where newOpenAt :: BitShown a -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' forall b c a. (b -> c) -> (a -> b) -> a -> c . forall a. BitShown a -> a bitShown {-# INLINE newOpenAt #-} instance NewOpenAt [Bool] where newOpenAt :: [Bool] -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt (DVS.Vector Word8) where newOpenAt :: Vector Word8 -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt (DVS.Vector Word16) where newOpenAt :: Vector Word16 -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt (DVS.Vector Word32) where newOpenAt :: Vector Word32 -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt (DVS.Vector Word64) where newOpenAt :: Vector Count -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt Word8 where newOpenAt :: Word8 -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt Word16 where newOpenAt :: Word16 -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt Word32 where newOpenAt :: Word32 -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-} instance NewOpenAt Word64 where newOpenAt :: Count -> Count -> Bool newOpenAt = forall a. (BitLength a, TestBit a) => a -> Count -> Bool newOpenAt' {-# INLINE newOpenAt #-}