packages feed

dhall-1.3.0: Prelude/Optional/concat

{-
Flatten two `Optional` layers into a single `Optional` layer

Examples:

```
./concat Integer ([[1] : Optional Integer] : Optional (Optional Integer))
= [1] : Optional Integer

./concat Integer ([[] : Optional Integer] : Optional (Optional Integer))
= [] : Optional Integer

./concat Integer ([] : Optional (Optional Integer))
= [] : Optional Integer
```
-}
let concat : ∀(a : Type) → Optional (Optional a) → Optional a
    =   λ(a : Type)
    →   λ(x : Optional (Optional a))
    →   Optional/fold
        (Optional a)
        x
        (Optional a)
        (λ(y : Optional a) → y)
        ([] : Optional a)

in  concat