2019-10-23 22:27:35 +03:00
|
|
|
|
The same kind of thing happens with `map`. Are we saying this is incorrect behaviour?
|
|
|
|
|
|
|
|
|
|
```unison
|
|
|
|
|
map : (a -> b) -> [a] -> [b]
|
2020-02-22 02:48:12 +03:00
|
|
|
|
map f = cases
|
2019-10-23 22:27:35 +03:00
|
|
|
|
x +: xs -> f x +: map f xs
|
|
|
|
|
[] -> []
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```ucm
|
|
|
|
|
|
|
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
|
change:
|
2020-02-07 05:46:23 +03:00
|
|
|
|
|
2019-10-23 22:27:35 +03:00
|
|
|
|
⍟ These new definitions are ok to `add`:
|
2020-02-07 05:46:23 +03:00
|
|
|
|
|
2019-10-23 22:27:35 +03:00
|
|
|
|
map : (a ->{𝕖} b) ->{𝕖} [a] ->{𝕖} [b]
|
2020-02-07 05:46:23 +03:00
|
|
|
|
|
2019-10-23 22:27:35 +03:00
|
|
|
|
Now evaluating any watch expressions (lines starting with
|
|
|
|
|
`>`)... Ctrl+C cancels.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```ucm
|
|
|
|
|
.> add
|
|
|
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
2020-02-07 05:46:23 +03:00
|
|
|
|
|
2019-10-23 22:27:35 +03:00
|
|
|
|
map : (a ->{𝕖} b) ->{𝕖} [a] ->{𝕖} [b]
|
|
|
|
|
|
|
|
|
|
.> view map
|
|
|
|
|
|
|
|
|
|
map : (a -> b) -> [a] -> [b]
|
2020-02-22 02:48:12 +03:00
|
|
|
|
map f = cases
|
|
|
|
|
x +: xs ->
|
|
|
|
|
use builtin.List +:
|
|
|
|
|
f x +: map f xs
|
|
|
|
|
[] -> []
|
2019-10-23 22:27:35 +03:00
|
|
|
|
|
|
|
|
|
.> find map
|
|
|
|
|
|
|
|
|
|
1. map : (a ->{𝕖} b) ->{𝕖} [a] ->{𝕖} [b]
|
2020-02-07 05:46:23 +03:00
|
|
|
|
|
2019-10-23 22:27:35 +03:00
|
|
|
|
|
|
|
|
|
```
|