4 ms·
This is common in Haskell as well using `newtype`. You can have type aliases like type A = B but you can use the following function with a B: f :: A -> _
by afraca 8y ago
This is common in Haskell as well using `newtype`. You can
have type aliases like
type A = B
but you can use the following function with a B:
f :: A -> _
whereas
newtype EscapedString = EscapedString String
f' :: EscapedString -> _
would prevent from using f' with the wrong data. Newtype is a zero-cost abstraction.