挖掘来源:
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
相匹配 - 来自a
的Respondable a => Affjax e a
? Zazchs的Respondable
实例:
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 where
匹配qazxsw poi。这是怎么回事?!
阐明孤独的兔子将来如何从类似的深洞中挖掘自己。 TNX!
我不确定我是否完全理解你的问题,但我认为你的问题源于Record
扩展类型别名的事实。让我们尝试手动执行此操作并检查它是否做得很好。您可以在定义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