Last active
August 29, 2015 14:07
-
-
Save munro/7a57a36cbf6eeac3a1a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Explicitly stating the order of computation `a (b c)` makes this not compile | |
-- While, if we used a C style, order of computation would be explicit by default `a(b(c))` vs `a(b, c)` | |
example1 = a b c | |
where | |
a first second = first ++ second | |
b = "hey" | |
c = " world" | |
-- Explicitly stating `a (b c)` makes this compile | |
example2 = a b c | |
where | |
a str = str | |
b str = "hey" ++ str | |
c = " world" | |
-- But we can create an unambiguous version of the function using tuples! | |
example3 = a(b, c) | |
where | |
a(first, second) = first ++ second | |
b = "hey" | |
c = " world" | |
main = do | |
putStrLn example1 | |
putStrLn example2 | |
putStrLn example3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OH MY GAWD
I was thinking about it more, and a problem with C-style is operators are an exception, because you obviously don't write
(123)+(321)
... that just looks weird. Also, like you said things likeif ... then ... else ...
could be thought of as a series of functions.Taking another look, Haskell style is really a super set of C-style, because as you demonstrated, you can replicate that style within Haskell! So an explicit set of arguments should be looked more as a type, being a tuple! Mondo cool.
This is my favorite part of Haskell! I love how it feels like I'm programming from left to right, not top to bottom.
Not sure what the proper term for
order of computation
is, perhaps the correct way for what I'm trying to say is: ambuguitiy in function application ... which is conceptually different to me than evaluation order.Thanks for the amazing response! You completed the puzzle in my head, ♡
#haskell
. If something I said sounds wrong please school me again.