Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is one of the things I like about Haskell. Operators like (-) are just like any other function, so you're free to redefine them for new input. If you want to define a world where 3 - 4 =5, you're free to do so. It makes it easy to explore some more complicated mathematical constructs.



Do you care to elaborate on how '3-4=5' allows one to explore some more complicated mathematical constructs? Unless 'complicated' means 'ilogical' I cannot understand it.

I think Haskell is a very nice language and it's flexibility on definitions is very cool, but I don't think this is a good example of it.


3-4=5 in Z6, the modulo group with six elements. See http://en.wikipedia.org/wiki/Modular_arithmetic


But you would never define it like this in Haskell...

You'd probably do something like: let n - m = ( n + (-m) ) `mod` 6

'let 3 - 4 = 5' is just a non-sense example.


For much the same reason, one would probably never want to write "let 1 = 1", but it's still a valid statement. It may not be interesting, but it's not nonsense.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: