[{"name":"Typed","comment":"\n\n@docs Typed\n\n\n## who can create\n\n\n### tagged creation\n\n@docs Tagged, tag, map, map2\n\n\n### checked creation\n\n@docs Checked, isChecked\n\n\n## who can access\n\n\n### public access\n\n@docs Public, val, val2\n\n\n### internal access\n\n@docs Internal, internalVal, internalVal2\n\n\n## compare\n\n@docs min, max\n\n\n## transform\n\n@docs serialize, serializeChecked\n\n","unions":[{"name":"Checked","comment":" Only someone with access to the `tag` constructor is able to create one of those.\n\nIn effect, this means that you can only let \"validated\" data be of this type.\n\nExample `... Checked ... NaturalNumberTag Int`\n\n→ **✓** not every `Int` can be called a `NaturalNumber`, it must be checked!\n\n","args":[],"cases":[]},{"name":"Internal","comment":" Only the ones with access to the `tag` constructor can access the `internalVal`.\n\nMeaning that access can be limited to\n\n  - inside a module\n\n```\nmodule Special exposing (Special)\n\ntype alias Special =\n    Typed Tagged SpecialTag Internal SpecialValue\n```\n\n  - inside a package (only with [`Checked`](#Checked))\n\n        Internal exposing (Tag(..))\n        A exposing (A)\n            import Internal exposing (Tag(..))\n        B exposing (B)\n            import Internal exposing (Tag(..))\n\n    ```json\n    'exposed-modules' : [ \"A\", \"B\" ]\n    ```\n\nThis generally helps hiding implementation details.\n\n    type alias OptimizedList a =\n        Typed Checked OptimizedListTag Internal (Implementation a)\n\n    type alias Implementation a =\n        { list : List a, length : Int }\n\n    toList --...\n\n","args":[],"cases":[]},{"name":"Public","comment":" Anyone is able to access the value.\n","args":[],"cases":[]},{"name":"Tagged","comment":" Anyone is able to create one of those.\n\nExample `Typed Tagged MetersTag ... Float`\n\n→ The right choice, as every `Float` is a valid description of `Meters`\n\n","args":[],"cases":[]},{"name":"Typed","comment":" A value is wrapped in the `type Typed` with a phantom `tag`.\n\nA `Typed ... Meters ... Float` can't be called a `Typed ... Kilos ... Float` anymore!\n\nFor `type`s with just 1 constructor with a value a `Typed` can be a good replacement.\n\n\n### who can construct such a value\n\n  - [`Checked`](#Checked)\n  - [`Tagged`](#Tagged)\n\n\n### who can access the value\n\n  - [`Public`](#Public)\n  - [`Internal`](#Internal)\n\nall promise additional type-safety.\n\n\n### reading types\n\n    map :\n        (value -> mappedValue)\n        -> Typed whoCanCreate_ tag whoCanAccess value\n        -> Typed Tagged tag whoCanAccess mappedValue\n\nIs saying:\n\n  - it works on every `Typed`\n  - it returns a value that is [`Tagged`](#Tagged), not [`Checked`](#Checked)\n  - if the input is [`Public`](#Public) or [`Internal`](#Internal), the result will be the same\n\nNote: Calling **`(==)` on `Typed`s causes elm to crash**.\nThis prevents users from finding out the inner value without using `val` or `internalVal` functions.\n\n","args":["whoCanCreate","tag","whoCanAccess","value"],"cases":[]}],"aliases":[],"values":[{"name":"internalVal","comment":" If you have an [`Internal`](#Internal) value, its value can't be read by users.\n\nHowever, if you have the `tag` constructor, you can access this value.\n\n    type alias OptimizedList a =\n        Typed\n            Checked\n            OptimizedListTag\n            Internal\n            { list : List a, length : Int }\n\n    type OptimizedListTag\n        = OptimizedList\n\n    toList =\n        internalVal OptimizedList >> .list\n\n","type":"tag -> Typed.Typed whoCanCreate_ tag whoCanAccess_ value -> value"},{"name":"internalVal2","comment":" Take 2 [`Internal`](#Internal) values with the same tag and combine them.\n\n    type alias OptimizedList a =\n        Typed\n            Checked\n            OptimizedListTag\n            Internal\n            { list : List a, length : Int }\n\n    type OptimizedListTag\n        = OptimizedList\n\n    equal a b =\n        internalVal2 (==) OptimizedList a b\n\nNote: Calling **`(==)` on `Typed`s causes elm to crash**.\nThis prevents users from finding out the inner value without using `val` or `internalVal` functions.\n\n","type":"(aValue -> bValue -> combinedValue) -> tag -> Typed.Typed whoCanCreateA_ tag whoCanAccessA_ aValue -> Typed.Typed whoCanCreateB_ tag whoCanAccessB_ bValue -> combinedValue"},{"name":"isChecked","comment":" After calling `tag` or modifying a checked value, you get a [`Tagged`](#Tagged). To tell the type that the result value is [`Checked`](#Checked), use `isChecked tag`.\n\nThe type of `tag` might even change in that operation.\n\n    oddPlusOdd : Odd -> Odd -> Even\n    oddPlusOdd oddToAdd =\n        Typed.map2 (+) oddToAdd\n            >> isChecked Even\n\n","type":"checkedTag -> Typed.Typed whoCanCreate_ tag_ whoCanAccess value -> Typed.Typed Typed.Checked checkedTag whoCanAccess value"},{"name":"map","comment":" Alter the value inside.\n\nIf the `Typed` was a [`Checked`](#Checked), it becomes a [`Tagged`](#Tagged).\n\n    type alias Meters =\n        Typed Tagged MetersTag Public Int\n\n    go1km : Meters -> Meters\n    go1km =\n        Typed.map ((+) 1000)\n\n","type":"(value -> mappedValue) -> Typed.Typed whoCanCreate_ tag whoCanAccess value -> Typed.Typed Typed.Tagged tag whoCanAccess mappedValue"},{"name":"map2","comment":" Use the values of 2 `Typed`s to return a `Tagged` result.\n\n    type alias PrimeNumber =\n        Typed Checked PrimeNumberTag Public Int\n\n    prime3 : PrimeNumber\n    prime3 =\n        tag 3 |> isChecked PrimeNumber\n\n    prime5 =\n        tag 5 |> isChecked PrimeNumber\n\nIn another module\n\n    type alias NonPrime =\n        Typed Checked NonPrimeTag Public Int\n\n    fromMultiplyingPrimes : Prime -> Prime -> NonPrime\n    fromMultiplyingPrimes aPrime bPrime =\n        Typed.map2 (*) aPrime bPrime\n            |> isChecked NonPrime\n\n","type":"(aValue -> bValue -> combinedValue) -> Typed.Typed whoCanCreateA_ tag whoCanAccess aValue -> Typed.Typed whoCanCreateB_ tag whoCanAccess bValue -> Typed.Typed Typed.Tagged tag whoCanAccess combinedValue"},{"name":"max","comment":" The greater of 2 `Typed` `comparable` [`Typed`](#Typed) values.\n\n    Typed.max three four\n    --> four\n\n","type":"Typed.Typed whoCanCreate tag whoCanAccess comparable -> Typed.Typed whoCanCreate tag whoCanAccess comparable -> Typed.Typed whoCanCreate tag whoCanAccess comparable"},{"name":"min","comment":" The smaller of 2 `Typed` `comparable` [`Typed`](#Typed) values.\n\n    Typed.min three four\n    --> three\n\n","type":"Typed.Typed whoCanCreate tag whoCanAccess comparable -> Typed.Typed whoCanCreate tag whoCanAccess comparable -> Typed.Typed whoCanCreate tag whoCanAccess comparable"},{"name":"serialize","comment":" A [`Codec`](https://package.elm-lang.org/packages/MartinSStewart/elm-serialize/latest/)\nto serialize [`Tagged`](#Tagged) [`Public`](#Public) [`Typed`](#Typed) values.\n","type":"Serialize.Codec error value -> Serialize.Codec error (Typed.Typed Typed.Tagged tag_ Typed.Public value)"},{"name":"serializeChecked","comment":" A [`Codec`](https://package.elm-lang.org/packages/MartinSStewart/elm-serialize/latest/) to serialize [`Typed`](#Typed) values.\n\nWe don't trust that the values we encode still have the same promises as our [`Checked`](#Checked) values.\n\nChoose a value it can convert from & to and serialize that.\n\n    module Nat exposing (serialize)\n\n    type NatTag\n        = Nat\n\n    serialize =\n        Serialize.int\n            |> Typed.serializeChecked Nat\n                (\\int ->\n                    if int >= 0 then\n                        Ok int\n\n                    else\n                        Err \"Int was negative, so it couldn't be decoded as a Nat\"\n                )\n                identity\n\n    module EfficientList exposing (serialize)\n\n    type EfficientListTag\n        = EfficientList\n\n    type alias EfficientList =\n        Typed Checked EfficientListTag\n            Internal { list : List a, length : Int }\n\n    serialize =\n        Typed.serializeChecked EfficientList\n            (\\list ->\n                { list = list\n                , length = List.length length\n                }\n                    |> Ok\n            )\n            .list\n            Serialize.list\n\n","type":"tag -> (value -> Result.Result error checkedValue) -> (checkedValue -> value) -> Serialize.Codec error value -> Serialize.Codec error (Typed.Typed Typed.Checked tag whoCanAccess_ checkedValue)"},{"name":"tag","comment":" Create a new [`Tagged`](#Tagged) value.\n\n  - can be [`Checked`](#Checked) with [`isChecked`](#isChecked)\n  - becomes [`Internal`](#Internal)/[`Public`](#Public) when annotated that way\n\nModifying won't change the type.\n\n","type":"value -> Typed.Typed Typed.Tagged tag_ whoCanAccess_ value"},{"name":"val","comment":" Read the value inside a [`Public`](#Public) `Typed`.\n","type":"Typed.Typed tag_ whoCanCreate_ Typed.Public value -> value"},{"name":"val2","comment":" Use the values of 2 [`Public`](#Public) `Typed`s to return a result.\n\n    type alias Prime =\n        Typed Checked PrimeTag Public Int\n\n    prime3 =\n        tag 3 |> isChecked Prime\n\n    prime5 =\n        tag 5 |> isChecked Prime\n\nAnywhere\n\n    val2 (+) prime3 prime5\n    --> 8\n\n    val2 Tuple.pair prime3 prime5\n    --> ( 3, 5 )\n\n    if val2 (<) onePrime otherPrime then\n\nNote: Calling **`(==)` on `Typed`s causes elm to crash**.\nThis prevents users from finding out the inner value without using `val` or `internalVal` functions.\n\n","type":"(aValue -> bValue -> resultValue) -> Typed.Typed aTag_ whoCanCreateA_ Typed.Public aValue -> Typed.Typed bTag_ whoCanCreateB_ Typed.Public bValue -> resultValue"}],"binops":[]}]