2 ms·
Your argument, unfortunately, doesn't really work, because for instance, in Haskell, data RGB = RGB Word8 Word8 Word8 The point made here has nothing to d
by jerf 14y ago
Your argument, unfortunately, doesn't really work, because for instance, in Haskell,
data RGB = RGB Word8 Word8 Word8
The point made here has nothing to do with weak typing. It just so happens his example sort of implies that he might be using it, since the author rather likes Erlang and that appears to be the syntax he reaches for, but the entire article applies without loss to strongly-typed languages as well. (Of which Haskell is merely a convenient example. Even more conventional manifest typing, as in C, works well enough here.) If you want to declare that you have a map of Booglies to Wangdoodles, it's trivial, but you're still using off-the-shelf maps and not bashing together trees yourself.
- danieldk 14y agoIn this case, Word8 applies nicely, but I'd like to point out that the argument doesn't fly either when something isn't nicely mapped to a type. E.g. (not checked): module Temperature ( TempCelsius tempCelsius ) where newtype TempCelsius = TempCelsius Double absoluteMinimum :: Double absoluteMinimum = -273.15 tempCelsius :: Double -> Maybe TempCelsius tempCelsius t | t < absoluteMinimum = Nothing | otherwise = Just $ TempCelsius t In other words, by hiding the constructor, you can control all access to a datatype. You could do the same with opaque pointers in C, etc.