- very strongly typed, you can even make sure you don't add Miles and Meters together, and that Meters * Meters give you square-meters
- destructors
- very strongly typed, you can even make sure you don't add Miles and Meters together, and that Meters * Meters give you square-meters
- destructors
I spent long time with VHDL, which is Ada with third leg. It is not nice language to work with.
These constraints can be much deeper. For example, I can define a function that allow me to add two somethings if their "regions" (a property I know how to compute) is equal and the result will be produced in "region" of first argument: add :: (Region a ~ Region b, Region a ~ Region c) => a -> b -> c
One use of something similar is addition of integer values represented by bit vectors in Verilog - you should not add bit vectors from different clock domains, otherwise you get unpredictable results.
ML modules are much more than generic packages. ML's module system allows you to take an existing module, hide some of its components, make some of its concrete types abstract, and get a new module. My methodology of enforcing only one invariant in each module is impracticable without ML modules.