Like the majority of ML languages. Haskell is pretty special here, being the descendant of Miranda.
Personally I think ML languages of OCaml branch are better for the general programmer public, as the entry level is a lower.
> 1.0;;
val it : float = 1.0
> 1;;
val it : int = 1
> 3.0 + 1.0;;
val it : float = 4.0
> 3 + 1;;
val it : int = 4
or strings > "3" + "4";;
val it : string = "34"
implicit conversion is not supported (good ihmo) > 3.0 + 1;;
3.0 + 1;;
------^
stdin(5,7): error FS0001: The type 'int' does not match the type 'float'My first contact with functional programming was with Caml Light back in 1996, OCaml's predecessor, which already has them.
My favourite programming languages are strong typed (e.g. Ada), so I guess it just felt natural back then.
However F# is the favourite one as nowadays I spend most of my time on Windows.
Two different operations, two different operators. Yes, C famously makes it easy to miss the extra `=` in if expressions, but that's C specifically, and it's not the fault of the operator, that's actually the fault of automatic conversions from int to bool. Static languages designed after I was born usually require boolean expressions in their `if` statements explicitly.
But `+` and `+.` are the same operation. Or are you saying that adding integers and adding reals are not the same operation, and thus warrant separate operators?
Another thing to consider is how you would implement having '+' for both integers and floats. In a language like C, '+' is designed for its numerical types, but what if you want to use it for big ints? Or for vectors? In a language like C++ you can overload operators, in Haskell or Rust operators are part of a typeclass or trait respectively; you need to add extra features to the language and the code generated by '+' is no longer a simple iadd or dadd instruction.
OCaml's choice may not be the best one or the most popular one, but I think it works fine.
http://ocaml.org/community/support.html#TheCamlConsortiumatI...
Then again, it's a very liberal language, if the end of the spectrum is Haskell. It allows side effects and mutable variables. While very convenient, nothing forces you to use these though. There are immutable data structures for everything. But it seems there are all the functional tools you'd want.
It's not Haskell, it's not pure and beautiful like it, but you still have computational expressions, which allow you to implement monads; metaprogramming, operator overloading, units of measure, and active patterns.
My only gripe is that the compiler doesn't translate functions that can return null to return an option value (i.e. Maybes), and null values in general! Would make interfacing the .NET library much cleaner. Right now I have to do something silly like this:
So I have to pipe every function call that may return null to this function when I'm in the Maybe monad, which is frankly a bit bothersome.Still. Even being able to use the Maybe monad when working with .NET is really cool.