jmpavlick/q/1.0.0

NOTE: the latest version is 1.1.0

A

Functions for navigating deeply-hierarchial nested values with optional properties.

The A module is specialized to operating on values that are not a Maybe a, but contain accessors that are "and-then-able".

import A
import Q


type alias User =
    { profile : Maybe { name : Maybe String, id : Int }




toUserName : User -> Maybe String
toUserName =
    A.qq .profile .name


toUserId : User -> Maybe Int
toUserId =
    A.qq .profile (Q.j .id)
qq : (a -> Maybe b) -> (b -> Maybe c) -> a -> Maybe c

Apply two "and-then-able" functions in order to a value.

qqq : (a -> Maybe b) -> (b -> Maybe c) -> (c -> Maybe d) -> a -> Maybe d

Apply three "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> a
-> Maybe e

Apply four "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> a
-> Maybe f

Apply five "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> a
-> Maybe g

Apply six "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> a
-> Maybe h

Apply seven "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> a
-> Maybe i

Apply eight "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> (i -> Maybe j)
-> a
-> Maybe j

Apply nine "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> (i -> Maybe j)
-> (j -> Maybe k)
-> a
-> Maybe k

Apply ten "and-then-able" functions in order to a value.

(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> (i -> Maybe j)
-> (j -> Maybe k)
-> (k -> Maybe l)
-> a
-> Maybe l

Apply eleven "and-then-able" functions in order to a value.

q6 :
(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> a
-> Maybe g

Same as qqqqqq, just easier to read.

q7 :
(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> a
-> Maybe h

Same as qqqqqqq, just easier to read.

q8 :
(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> a
-> Maybe i

Same as qqqqqqqq, just easier to read.

q9 :
(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> (i -> Maybe j)
-> a
-> Maybe j

Same as qqqqqqqqq, just easier to read.

q10 :
(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> (i -> Maybe j)
-> (j -> Maybe k)
-> a
-> Maybe k

Same as qqqqqqqqqq, just easier to read.

q11 :
(a -> Maybe b)
-> (b -> Maybe c)
-> (c -> Maybe d)
-> (d -> Maybe e)
-> (e -> Maybe f)
-> (f -> Maybe g)
-> (g -> Maybe h)
-> (h -> Maybe i)
-> (i -> Maybe j)
-> (j -> Maybe k)
-> (k -> Maybe l)
-> a
-> Maybe l

Same as qqqqqqqqqqq, just easier to read.