# Flip For Non-Numeric Data Type

**URL:** <https://forum.canton.network/t/flip-for-non-numeric-data-type/1276>\
**Category:** App Development\
**Created:** [September 23, 2020, 9:22am UTC](https://forum.canton.network/t/flip-for-non-numeric-data-type/1276 "2020-09-23T09:22:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carleslabon](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/carleslabon/32/6481_2.png) [@carleslabon](https://forum.canton.network/u/carleslabon)\
**Post date:** [September 23, 2020, 9:22am UTC](https://forum.canton.network/t/flip-for-non-numeric-data-type/1276/1 "2020-09-23T09:22:16Z")

</div>

Hello good evening. I just want to ask a sample of using flip within a non-numeric data type, since I’m having a hard time creating one. Thanks!

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [September 23, 2020, 9:39am UTC](https://forum.canton.network/t/flip-for-non-numeric-data-type/1276/2 "2020-09-23T09:39:02Z")

</div>

Maybe one related to your [`mapA`, `forA` question](https://discuss.daml.com/t/mapa-fora-difference/1270/6):

```haskell
forA = flip mapA

```

That is actually [how `forA` is implemented](https://github.com/digital-asset/daml/blob/cd4a06db95b454f9053d8accd2dbd14b8f55f6b8/compiler/damlc/daml-stdlib-src/DA/Internal/Prelude.daml#L393-L395).

[`flip`](https://docs.daml.com/daml/stdlib/Prelude.html#function-da-internal-prelude-flip-57699) just changes the order of the arguments of a two parameter function:

```haskell
flip : (a -> b -> c) -> (b -> a -> c)
flip fn x y = fn y x

```

Note that I’ve added parentheses for clarity above. The actual signature is `(a -> b -> c) -> b -> a -> c` which is equivalent by associativity. But basically, stick a function with two parameters of types `a` and `b` in, get a function with two parameters of types `b` and `a` out.

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [September 23, 2020, 7:33pm UTC](https://forum.canton.network/t/flip-for-non-numeric-data-type/1276/3 "2020-09-23T19:33:43Z")

</div>

On a lighter note, your pointer made me notice this code that makes even too much sense:

> <https://github.com/digital-asset/daml/blob/cd4a06db95b454f9053d8accd2dbd14b8f55f6b8/compiler/damlc/daml-stdlib-src/DA/Internal/Prelude.daml#L402-L404>
