[{"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, internal\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\nExamaple `... 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 `Typed.internal`.\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":"internal","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":"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 -> value) -> Typed.Typed whoCanCreateA tag whoCanAccess value -> Typed.Typed whoCanCreateB tag whoCanAccess value -> Typed.Typed Typed.Tagged tag whoCanAccess value"},{"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\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        Serialize.map .list identity\n            |> Serialize.list\n            |> Typed.serializeChecked EfficientList\n                (\\list ->\n                    { list = list\n                    , length = List.length length\n                    }\n                        |> Ok\n                )\n\n","type":"tag -> (value -> Result.Result error value) -> Serialize.Codec error value -> Serialize.Codec error (Typed.Typed Typed.Checked tag whoCanAccess value)"},{"name":"tag","comment":" Create a new tagged value.\n\n  - can be `Checked` with [`isChecked`](Typed#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 `Accessible`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":[]}]