Not in the standard library. That sort of representation is hard to implement. In a quick search of Hackage I turned up some algebra packages, but they don’t appear to come with implementations of Num or be intended for that kind of use. Performance would be bad, also…
[Comment removed by author]
Slightly incorrect–Javascript numbers are double-precision (64-bit) floats (see old writeup here).
If you need 32-bit floats (say, for WebGL interop), you use typed arrays.
Does haskell have an algebraic type?
Not in the standard library. That sort of representation is hard to implement. In a quick search of Hackage I turned up some algebra packages, but they don’t appear to come with implementations of Num or be intended for that kind of use. Performance would be bad, also…
You should and people typical do expect arithmetic to work correctly for integer values and integer results in Javascript.