に1 ResumableSourceを追加は?ここでは下記のおもちゃの一例である - b
がそれを持っていませんがa
はMonad
制約があります。だから我々はa's
なくb's
を追加することができますは、彼らが明示的<code>Monad</code>のインスタンスでないときは、別のものに1 <code>ResumableSource</code>を追加するにはどうすればよい別の
Prelude> import Data.Conduit
Prelude Data.Conduit> import Data.ByteString as BS
Prelude Data.Conduit BS> import Control.Monad.Trans.Resource
Prelude Data.Conduit BS Control.Monad.Trans.Resource> let a = newResumableSource (yield (BS.pack [5])) -- this one has monad constraint
Prelude Data.Conduit BS Control.Monad.Trans.Resource> :t a
a :: Monad m => ResumableSource m ByteString
Prelude Data.Conduit BS Control.Monad.Trans.Resource> :t a >> a
a >> a
:: (Monad m, Monad (ResumableSource m)) =>
ResumableSource m ByteString
Prelude Data.Conduit BS Control.Monad.Trans.Resource> let b = undefined :: ResumableSource (ResourceT IO) ByteString
Prelude Data.Conduit BS Control.Monad.Trans.Resource> :t b >> b
<interactive>:1:3:
No instance for (Monad (ResumableSource (ResourceT IO)))
arising from a use of ‘>>’
In the expression: b >> b
私はそれを求めていた理由を、私は、上記のb
と同じ型を持つHTTP ResumableSource
を持って、私はそれを供給する前に、コンテンツの長さを付加するようになるためにどのので、シンク。私はこのようなものに変更するようになる
responseBody rsp $$+- sink
:ResumableSource
に初期メッセージを付加する
((newResumableSource (yield content-len)) >> (responseBody rsp)) $$+- sink
注注意深く '>> A ::の推論型(モナドのM、モナド(ResumableSourceのM))=> ResumableSource M ByteString'。 'm'をインスタンス化すると、精巧さは' Monad(ResumableSource m) 'のインスタンスを検索します。 'ResumableSource'は' Monad'インスタンスを持たないので、型検査は失敗します。言い換えれば、 'a >> a'を使用する方法はありません。 –
ha、うん、良い点。最初の情報源が終わった後にシンクがなくなると、私は降伏するしかないのだろうか? 'yield content-len $$ sinkのように。 (responseBody rsp))$$ + - sink'となります。 – Sal