Simplify Monadic Type Signature in Haskell -
I'm still new in Haskell and having trouble finding the right type signature for the function.
I have this work, using a simple code like http: // -conuit and I would like to specify the correct type of signature, but output from GHCi looks terrible to me: The first three arguments ( Instead of just providing the correct signature, I want to understand how the process of finding and reducing the right one looks like. The GHCI is giving you the most polymorphic signature, "any type of Here's a simple example: So if you only use your function in Or you can keep polymorphic signatures, for example if you are exporting this function to the library and you think That your users should use it in a different mood (perhaps by defining their new type and making it an example of authenticate-oauth which is a side effect, so I There is not much care about the return value:
manager $ \ manager with executeOAuthRequest oAuth credit request = - - & gt; Signed & lt; - signOAuth oauth credit request http signed manager
executeOAuthRequest: : (Monad-control-0.3.2.3: Control.Monad.Trans.Control.MonadBaseControl IO m, control. MONAD.Trans.Resource.Internal.MonadThrowM, ControlMonad. Trans.Resource.Internal .MonadUnsafeIO m, Control Monad.IO.Class.MonadIO m) => OAuth - & gt; Credential - & gt; Request - & gt; M (ResumableSource (Resourceable M ByteString))
OAuth ,
credentials ,
requests < / Code>) I understand, but I do not understand the long pre-condition for
m and wondered if it is necessary to specify the full return value as per the suggestion of GHCi.
m There is an example from MonadTrans which is reading from
MonadThrow .Resource.Entertent module,
Monadio , etc. "all types of typed checkers Is taking the union of those who have been started with the type of multicultural tasks you are making in the
executeOAuthRequest .
prelude & gt; F f n = n + 1 prelude & gt; : TF - GHC estimates the polymorphic signature which is `NO ': V: number: = one => A - & gt; A Prelude & gt; F: int - & gt; Int; f n = n + 1 prelude & gt; : Tff :: int - & gt; It may be that the only way to satisfy all those constraints in your work is either
IO , or there may be many common ways to check demo Have to read or depress
prelude & gt; : Info IO ... Example Monad Io - Defined in GACC. Example Factor IO - Defined in GACC. Introduction & gt; : Info Monaad ... Examples Monad [] - Defined in GHC. Example Monad Io - Defined in GACC. Example Monaad ((- -> R) - Defined in GACC.
IO , then you can type it:
executeOAuthRequest: : OAuth - & gt; Credential - & gt; Request - & gt; IO (RespumableSource (ResourceTM) bytestrings))
MonadIO ,
MonadThrow , etc.) / html>
Comments
Post a Comment