---
title: "U2021: A function with `edit` or `take` parameters used as a value"
url: https://una-lang.org/en/docs/errors/U2021/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2021.md
---

# U2021: A function with `edit` or `take` parameters used as a value

Function types have no conventions, so a function with an `edit` or `take` parameter cannot be used as a value: naming it anywhere but in the callee position of a call is U2021 (`spec/17 §3` rule 7). Call it directly, or wrap the call in a function or lambda without conventions.

## The repair at a glance

`src/demo.una`

```diff
  module demo

- pub drain(take items: List[Int]) -> Int = items.len
+ pub size(items: List[Int]) -> Int = items.len

- pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: drain)
+ pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: size)
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"
```

`src/demo.una`

```una
module demo

pub drain(take items: List[Int]) -> Int = items.len

pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: drain)
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"
```

`src/demo.una`

```una
module demo

pub size(items: List[Int]) -> Int = items.len

pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: size)
```
