如何访问Data.Functor.Of?

How to access Data.Functor.Of?

我正在尝试使用 streaming-bytestring Data.ByteString.Streaming.Char8 库的 length 函数。

我看到 return 值的类型为 Of,但我不清楚如何检查它。我尝试使用 case,但编译器显示 Not in scope: data constructor ‘O.Of’,即使我对 Data.Functor.Of.

进行了合格导入

如何检查值?

代码示例:

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 :>

所以你应该可以做类似

的事情
n :> _ <- length bs