4 ms·
These are sometimes called "strong" or phantom types in other languages, e.g.: https://github.com/mapbox/cpp/blob/master/docs/strong_types.md https://github.com
by kookamamie 2y ago
These are sometimes called "strong" or phantom types in other languages, e.g.: https://github.com/mapbox/cpp/blob/master/docs/strong_types.md https://github.com/mapbox/cpp/blob/master/docs/strong_types....
- jweir 2y agoElm makes great use of these, for example in the Units package: https://package.elm-lang.org/packages/ianmackenzie/elm-units/latest/ https://package.elm-lang.org/packages/ianmackenzie/elm-units... Very nice to prevent conversions between incompatible units, but without the over head of lots of type variants. https://thoughtbot.com/blog/modeling-currency-in-elm-using-phantom-types https://thoughtbot.com/blog/modeling-currency-in-elm-using-p...