I am trying to use the length function of the streaming-bytestring
Data.ByteString.Streaming.Char8
library.
I see that the return value has type Of
, but I am not clear on how to examine it. I tried using case
, but the compiler says Not in scope: data constructor ‘O.Of’
, even if I do a qualified import of Data.Functor.Of
.
How do I examine the value?
Code sample:
ghci> let bs = BSSC.string "tiger"
ghci> bs
Chunk "tiger" (Empty (()))
ghci> BSSC.length bs
6 :> ()
ghci> let len = BSSC.length bs
ghci> :t len
len :: Monad m => m (OO.Of Int ())
The constructor of Of
is called (:>)
:
-- | A left-strict pair; the base functor for streams of individual elements.
data Of a b = !a :> b
deriving (Data, Eq, Foldable, Ord,
Read, Show, Traversable, Typeable, Generic, Generic1)
infixr 5 :>
so you should be able to do something like
n :> _ <- length bs