On this page:
3.5.1 类型类定义
gen:  Functor
functor:  map
Functor?
3.5.2 函子函数
map
<$>
<#>
<$
$>
8.12

3.5 Functor(函子)🔗

3.5.1 类型类定义🔗

Functor接口。

procedure

(functor:map f ma)  Functor?

  f : (-> a b)
  ma : Functor?
Functor的最小实现。

procedure

(Functor? a)  boolean?

  a : any/c
是不是gen:Functor实例。

3.5.2 函子函数🔗

procedure

(map f ma)  Functor?

  f : (-> a b)
  ma : Functor?
functor:map柯里化版本。

Examples:
> (map add1 (list 1 2 3))

'(2 3 4)

> (map add1 (hash 1 2 3 4))

'#hash((1 . 3) (3 . 5))

procedure

(<$> f ma)  Functor?

  f : (-> a b)
  ma : Functor?
map别名。

procedure

(<#> ma f)  Functor?

  ma : Functor?
  f : (-> a b)
map参数反转版本。

(define <#> (flip map))

procedure

(<$ a ma)  Functor?

  a : a
  ma : Functor?
替换为常量a

Examples:
> (<$ 1 (list 1 2 3 4 4 5))

'(1 1 1 1 1 1)

> (<$ 2 (hash 11 12 13 14))

'#hash((11 . 2) (13 . 2))

procedure

($> ma a)  Functor?

  ma : Functor?
  a : any/c
<$反转参数版本。