通过消息来源进行挖掘:
https://github.com/slamdata/purescript-affjax/blob/v5.0.0/src/Network/HTTP/Affjax.purs#L92
偶然发现了get的签名
get :: forall e a. Respondable a => URL -> Affjax e a并冒险进入psci:
> import Network.HTTP.Affjax
> :t get
forall e a.
Respondable a => String
-> Aff
( ajax :: AJAX
| e
)
{ status :: StatusCode
, headers :: Array ResponseHeader
, response :: a
}集中于返回类型的尾部部分,如何:
Respondable a =>
{ status :: StatusCode
, headers :: Array ResponseHeader
, response :: a
}与第一个签名中的Respondable a匹配--来自Respondable a => Affjax e a的a?Respondable实例的Zilch
instance responsableBlob :: Respondable Blob where
instance responsableDocument :: Respondable Document where
instance responsableForeign :: Respondable Foreign where
instance responsableString :: Respondable String where
instance responsableUnit :: Respondable Unit where
instance responsableArrayBuffer :: Respondable A.ArrayBuffer where
instance responsableJson :: Respondable Json wherematche Record.瓦特在继续吗!
阐明了独行兔今后如何从类似的深孔中挖出自己。Tnx!
发布于 2017-12-22 21:37:07
我不确定我是否完全理解您的问题,但我认为您的问题是因为psci扩展了类型别名这一事实。让我们尝试手动完成这项工作,并检查它是否做得很好。您可以在定义get的同一文件中找到这些类型别名:
type Affjax e a =
Aff
(ajax :: AJAX | e)
(AffjaxResponse a)
type AffjaxResponse a =
{ status :: StatusCode
, headers :: Array ResponseHeader
, response :: a
}因此,考虑到get有类型:
get :: forall e a
. Respondable a
=> URL
-> Affjax e a我们可以试着用所有的化名来代替。为了提高可读性,我在这里使用垂直格式。让我们为Affjax a e使用第一个别名
-- using first alias
get :: forall e a
. Respondable a
=> URL
-> Aff
(ajax :: AJAX | e)
(AffjaxResponse a)现在AffjaxResponse a排名第二
get :: forall e a
. Respondable a
=> URL
-> Aff
(ajax :: AJAX | e)
{ status :: StatusCode
, headers :: Array ResponseHeader
, response :: a
}https://stackoverflow.com/questions/47943917
复制相似问题