[{"name":"Typed","comment":"\n\n@docs Typed\n\n\n## who can create\n\n\n### tagged\n\n@docs Tagged, tag, map, map2\n\n\n### checked\n\n@docs Checked, isChecked\n\n\n## who can access\n\n\n### Public\n\n@docs Public, val, val2\n\n\n### internal\n\n@docs Internal, internalVal, internalVal2\n\n\n## compare\n\n@docs min, max\n\n\n## serialize\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`)\n\n```\nsrc\n  └ Special\n      └ Internal.elm\n          module Special.Internal exposing (SpecialTag(..))\n  └ SpecialPartA.elm\n      module SpecialPartA exposing (SpecialPartA)\n      import Special.Internal exposing (SpecialTag(..))\n  └ SpecialPartB.elm\n      module SpecialPartB exposing (SpecialPartB)\n      import Special.Internal exposing (SpecialTag(..))\nelm.json 'exposed-modules' :\n  [ \"SpecialPartA\", \"SpecialPartB\" ]\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`](Typed#Checked)\n\n  - [`Tagged`](Typed#Tagged)\n\n\n### who can access the value\n\n  - [`Public`](Typed#Public)\n\n  - [`Internal`](Typed#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\n\nIs saying: `map` works on every `Typed` and returns a value that is just `Tagged`, but not `Checked`.\nExplaining `whoCanAccess`:\n\n  - If the input is `Public`\n  - If the input is `Internal`,\n\nthe result will be too.\n\n","args":["whoCreated","tag","whoCanAccess","value"],"cases":[]}],"aliases":[],"values":[{"name":"internalVal","comment":" If you have an `Internal`, its value isn't readable by users.\n\nIf you have the `tag` however, you can access this data hidden from users.\n\n","type":"tag -> Typed.Typed whoCanCreate_ tag Typed.Internal value -> value"},{"name":"internalVal2","comment":" Use the values of 2 `Internal` `Typed`s to return a result.\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 OptimizedList b\n\n","type":"(aValue -> bValue -> resultValue) -> aTag -> Typed.Typed whoCreatedA_ aTag Typed.Internal aValue -> bTag -> Typed.Typed whoCreatedB_ bTag Typed.Internal bValue -> resultValue"},{"name":"isChecked","comment":" After calling `tag` or modifying a checked value, you get a `Tagged`. To tell the type that the result value is `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 whoCreated_ tag_ whoCanAccess_ value -> Typed.Typed Typed.Checked checkedTag whoCanAccessChecked_ value"},{"name":"map","comment":" Alter the value inside.\n\nIf the `Typed` was a `Checked`, it becomes a `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 whoCreated_ 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":"(value -> value -> mappedValue) -> Typed.Typed whoCanCreateA_ tag whoCanAccess value -> Typed.Typed whoCanCreateB_ tag whoCanAccess value -> Typed.Typed Typed.Tagged tag whoCanAccess mappedValue"},{"name":"max","comment":" The greater of 2 `Typed` `comparable` values.\n\n    Typed.max three four\n\n","type":"Typed.Typed whoCreated tag Typed.Public comparable -> Typed.Typed whoCreated tag Typed.Public comparable -> Typed.Typed whoCreated tag Typed.Public comparable"},{"name":"min","comment":" The smaller of 2 `Typed` `comparable` values.\n\n    Typed.max three four\n\n","type":"Typed.Typed whoCreated tag Typed.Public comparable -> Typed.Typed whoCreated tag Typed.Public comparable -> Typed.Typed whoCreated tag Typed.Public comparable"},{"name":"serialize","comment":" A [`Codec`](https://package.elm-lang.org/packages/MartinSStewart/elm-serialize/latest/) to serialize `Tagged` `Public` `Typed`s.\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 `Checked`s.\n\nWe don't trust that the values we encode still have the same promises as our `Checked`s.\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 value.\n\n  - can be `Checked` with [`isChecked`](#isChecked)\n  - becomes `Internal/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` `Typed`.\n","type":"Typed.Typed whoCreated_ tag_ Typed.Public value -> value"},{"name":"val2","comment":" Use the values of 2 `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\n","type":"(aValue -> bValue -> resultValue) -> Typed.Typed whoCreatedA_ aTag_ Typed.Public aValue -> Typed.Typed whoCreatedB_ bTag_ Typed.Public bValue -> resultValue"}],"binops":[]}]