Morgan-Stanley / morphir-elm / Morphir.SDK.Key

Helpers to work with composite keys.

Motivation

It is difficult to work with composite keys in Elm due to various limitations:

This library resolves those issues by introducing type aliases for keys of various element sizes. All these types are comparable and they all have utility functions to compose them. Here's an example:

type alias MyEntity =
    { foo : String
    , bar : Int
    , baz : Float
    }

-- myKey : Key3 Int String Float
myKey =
    key3 .bar .foo .baz

Note: This file was generated using Elm code that is included as a comment at the end of the source code for this module. You can use that code to extend this module without too much manual work.

Composing Keys

noKey : Key0

Creates a key with zero elements.

key0 : Key0

Creates a key with zero elements.

key2 : (a -> comparable1) -> (a -> comparable2) -> a -> Key2 comparable1 comparable2

Create a composite key with 2 elements.

key3 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> a -> Key3 comparable1 comparable2 comparable3

Create a composite key with 3 elements.

key4 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> a -> Key4 comparable1 comparable2 comparable3 comparable4

Create a composite key with 4 elements.

key5 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> a -> Key5 comparable1 comparable2 comparable3 comparable4 comparable5

Create a composite key with 5 elements.

key6 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> a -> Key6 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6

Create a composite key with 6 elements.

key7 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> a -> Key7 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7

Create a composite key with 7 elements.

key8 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> a -> Key8 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8

Create a composite key with 8 elements.

key9 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> a -> Key9 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9

Create a composite key with 9 elements.

key10 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> a -> Key10 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10

Create a composite key with 10 elements.

key11 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> (a -> comparable11) -> a -> Key11 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10 comparable11

Create a composite key with 11 elements.

key12 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> (a -> comparable11) -> (a -> comparable12) -> a -> Key12 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10 comparable11 comparable12

Create a composite key with 12 elements.

key13 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> (a -> comparable11) -> (a -> comparable12) -> (a -> comparable13) -> a -> Key13 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10 comparable11 comparable12 comparable13

Create a composite key with 13 elements.

key14 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> (a -> comparable11) -> (a -> comparable12) -> (a -> comparable13) -> (a -> comparable14) -> a -> Key14 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10 comparable11 comparable12 comparable13 comparable14

Create a composite key with 14 elements.

key15 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> (a -> comparable11) -> (a -> comparable12) -> (a -> comparable13) -> (a -> comparable14) -> (a -> comparable15) -> a -> Key15 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10 comparable11 comparable12 comparable13 comparable14 comparable15

Create a composite key with 15 elements.

key16 : (a -> comparable1) -> (a -> comparable2) -> (a -> comparable3) -> (a -> comparable4) -> (a -> comparable5) -> (a -> comparable6) -> (a -> comparable7) -> (a -> comparable8) -> (a -> comparable9) -> (a -> comparable10) -> (a -> comparable11) -> (a -> comparable12) -> (a -> comparable13) -> (a -> comparable14) -> (a -> comparable15) -> (a -> comparable16) -> a -> Key16 comparable1 comparable2 comparable3 comparable4 comparable5 comparable6 comparable7 comparable8 comparable9 comparable10 comparable11 comparable12 comparable13 comparable14 comparable15 comparable16

Create a composite key with 16 elements.

Key Types


type alias Key0 =
Basics.Int

Type that represents a zero element key. The ideal representation would be () but Unit is not comparable in Elm. So we use Int to retain comparable semantics but only 0 should be used as a value. key0 and noKey can be used to create a Key0 value.


type alias Key2 k1 k2 =
( k1, k2 )

Type that represents a composite key with 2 elements.


type alias Key3 k1 k2 k3 =
( k1, k2, k3 )

Type that represents a composite key with 3 elements.


type alias Key4 k1 k2 k3 k4 =
( k1, k2, ( k3, k4 ) )

Type that represents a composite key with 4 elements.


type alias Key5 k1 k2 k3 k4 k5 =
( k1, k2, ( k3, k4, k5 ) )

Type that represents a composite key with 5 elements.


type alias Key6 k1 k2 k3 k4 k5 k6 =
( k1, k2, ( k3, k4, ( k5, k6 ) ) )

Type that represents a composite key with 6 elements.


type alias Key7 k1 k2 k3 k4 k5 k6 k7 =
( k1, k2, ( k3, k4, ( k5, k6, k7 ) ) )

Type that represents a composite key with 7 elements.


type alias Key8 k1 k2 k3 k4 k5 k6 k7 k8 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8 ) ) ) 
)

Type that represents a composite key with 8 elements.


type alias Key9 k1 k2 k3 k4 k5 k6 k7 k8 k9 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, k9 ) ) ) 
)

Type that represents a composite key with 9 elements.


type alias Key10 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10 ) ) ) ) 
)

Type that represents a composite key with 10 elements.


type alias Key11 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10
, k11 ) ) ) ) 
)

Type that represents a composite key with 11 elements.


type alias Key12 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10
, ( k11
, k12 ) ) ) ) ) 
)

Type that represents a composite key with 12 elements.


type alias Key13 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 k13 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10
, ( k11
, k12
, k13 ) ) ) ) ) 
)

Type that represents a composite key with 13 elements.


type alias Key14 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 k13 k14 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10
, ( k11
, k12
, ( k13
, k14 ) ) ) ) ) ) 
)

Type that represents a composite key with 14 elements.


type alias Key15 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 k13 k14 k15 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10
, ( k11
, k12
, ( k13
, k14
, k15 ) ) ) ) ) ) 
)

Type that represents a composite key with 15 elements.


type alias Key16 k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 k13 k14 k15 k16 =
( k1
, k2
, ( k3
, k4
, ( k5
, k6
, ( k7
, k8
, ( k9
, k10
, ( k11
, k12
, ( k13
, k14
, ( k15
, k16 ) ) ) ) ) ) ) 
)

Type that represents a composite key with 16 elements.