A categorical programming language
修订版 | ed5150e18a278c754349c9f9087aab23400c6cf8 (tree) |
---|---|
时间 | 2022-03-02 12:36:12 |
作者 | Corbin <cds@corb...> |
Commiter | Corbin |
Get everything in the hive typechecked.
Had to remove three experiments which didn't work out. We can always
revisit them later.
@@ -337,7 +337,7 @@ class Fold(Arrow): | ||
337 | 337 | cdom, ccod = self._c.types(cs) |
338 | 338 | cs.unify(ndom, cs.concrete("1")) |
339 | 339 | x = cs.fresh() |
340 | - cs.unify(cdom, cs.functor("pair", [ccod, x])) | |
340 | + cs.unify(cdom, cs.functor("pair", [x, ccod])) | |
341 | 341 | cs.unify(ncod, ccod) |
342 | 342 | return cs.functor("list", [x]), ccod |
343 | 343 |
@@ -47,6 +47,7 @@ class CammyParser(object): | ||
47 | 47 | args = [] |
48 | 48 | while not self.canAndDoesEat(')'): |
49 | 49 | args.append(self.takeExpression()) |
50 | + self.eatWhitespace() | |
50 | 51 | return Functor(head, args) |
51 | 52 | |
52 | 53 |
@@ -4,6 +4,9 @@ | ||
4 | 4 | (f/divpair |
5 | 5 | (comp fun/swap f-atan2) |
6 | 6 | (fun/const (f/mulpair f-pi f/2))) |
7 | - (comp f/2 f-recip)) | |
7 | + (fun/const (comp f/2 f-recip))) | |
8 | 8 | (f/mulpair v2/norm (fun/const f/2))) |
9 | 9 | hv2rgb) |
10 | + | |
11 | +Map a complex number to a color. The magnitude is mapped to luminance and the | |
12 | +angle is mapped to hue. |
@@ -1,3 +0,0 @@ | ||
1 | -(curry (pair | |
2 | - (comp (pair (comp fst fst) (comp snd fst)) (uncurry nat/add)) | |
3 | - (comp (pair (comp fst snd) (comp snd snd)) (uncurry nat/add)))) |
@@ -1 +0,0 @@ | ||
1 | -(curry (comp (pair id int/neg) (uncurry int/add))) |
@@ -1 +0,0 @@ | ||
1 | -(comp (comp (pair id (fun/const zero)) list/repeat) (list/scan zero nat/add)) |
@@ -2,3 +2,5 @@ | ||
2 | 2 | (comp zero (pair id succ)) |
3 | 3 | (comp (pair (comp fst succ) snd) (pair fst nat/mul)) |
4 | 4 | ) snd) |
5 | + | |
6 | +The factorial function on natural numbers. |