Comparison of SML and Haskell
Similarities
There are lots!
- Functions are values, arbitrary higher-order functions
- Algebraic data types + pattern matching
- Hindley-Milner type inference
- Parametric polymorphism
Some differences
Haskell features
- Purity!
- Referential transparency: always safe to substitute x = y
- Side effects are reflected in the type system
- More parallelizable
- Lazy evaluation
- Separation of concerns
- Trivially support infinite data structures
- Cleaner syntax, nice sugar
- Far fewer keywords, better consistency
- Nice sugar for monadic programming and list comprehensions
- Type classes
- Less powerful than SML’s modules, more convenient; sweet spot?
- Nicer solution to equality and operator overloading
- Minimalistic module system
- Manages namespace only
SML features
- Arbitrary side-effects
- Often convenient
- Pure functions are considered good style
- Strict evaluation
- Easier to reason about time and (especially) space performance
- Some theoretical advantages (one bottom per type)
- Expressive module system
- Separates module interfaces (signatures) from implementation (structures)
- Allows many-to-many relationships between them
- Supports hierarchical modules and parameterized modules (functors)
- Not tied to the file system
- Separates module interfaces (signatures) from implementation (structures)