挖掘来源:
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
的{{1}}? Zilch的Respondable a => Affjax e a
实例:
Respondable
matche 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
。 Waat正在继续?!
说明孤独的兔子将来如何从类似的深洞挖掘自己。 TNX!
答案 0 :(得分:2)
我不确定我是否完全理解您的问题,但我认为您的问题源于df2=
structure(list(Q7 = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 3L), .Label = c("A", "B", "C"), class = "factor"),
x1 = c(13L, 31L, 17L, 27L, 24L, 21L, 34L, 28L, 13L, 25L,
12L, 16L, 26L, 27L, 20L), x2 = c(32L, 29L, 16L, 27L, 27L,
22L, 36L, 35L, 22L, 27L, 13L, 30L, 17L, 27L, 9L), x3 = c(29L,
13L, 18L, 25L, 19L, 21L, 24L, 22L, 30L, 30L, 14L, 28L, 19L,
11L, 13L)), .Names = c("Q7", "x1", "x2", "x3"), class = "data.frame", row.names = c(NA,
-15L))
扩展类型别名的事实。
让我们尝试手动执行此操作并检查它是否做得很好。您可以在定义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