Question: I have a quite simple question.
Can me someone tell, why the status of the checkboxes doesn't change?
The booleans in check change, but not the status of the checkboxes.

```
function KP() {
  const [name] = useState(["1", "2"]);
  const [check, setCheck] = useState([true, false]);

  const handleChange = (event) => {
    const { id, checked } = event.target;
    const index = name.indexOf(id);
    var temp = check;
    temp[index] = checked;
    setCheck(temp);
  };

  return (
    <div>
      {name.map((n, index) => {
        return (
          <div>
            <p>{n}</p>
            <input type="checkbox" checked={check[index]} onChange={handleChange} id={n} key={n}/>
          </div>
        );
      })}

    </div>
  );
}

```

Answer: 
In Scala 2 it is impossible to define parametric function, only method.

In Scala 3 [polymorphic function type](https://dotty.epfl.ch/docs/reference/new-types/polymorphic-function-types.html) is introduced:

```
val fun: [A] => A => Unit = [A] => a => println(a.toString)

```

Workaround used in 2 by Cats and friends were traits with polymorphic `apply`

```
trait MySpecialFunctionlikeThing {
  def apply[A](a: A): Unit
}

```

Unfortunately, single abstract method (SAM) doesn't work with things like that, so some tricks were used to make it easy to lift function into such methods:

```
object MySpecialFunctionlikeThing {

  type Arbitrary

  def lift(f: Arbitrary => Unit): MySpecialFunctionlikeThing =
    new MySpecialFunctionlikeThing {
      def apply[A](a: A): Unit = f(a.asInstanceOf[Arbitrary])
    }
}

val fun = MySpecialFunctionlikeThing.lift(a => println(a))

```

The latter I saw in several different forms: the above, one using existential types and one using one of the above for method signature and macro for implementation (see [`FunctionK.lift`](https://github.com/typelevel/cats/blob/8e8be51187385dde78321e7e0d9fd892801afacb/core/src/main/scala-2.x/src/main/scala/cats/arrow/FunctionKMacros.scala#L29)).

Quite often, though, you can get away with what you used that is parametric, nullary method returning non-parametric function.

```
def fun[A]: A => Unit = a => println(a)

```
This would require higher-rank types, which isn't supported in Scala 2.

It is supported in Scala 3:
<https://dotty.epfl.ch/docs/reference/new-types/polymorphic-function-types.html>