Well I decided to look into learning Haskell, since I found myself growing more and more interested about functional programming instead of imperative programming. So I finally found a tutorial that made sense to me and went slow enough, so I'm happy . The thing is, it doesn't explain everything pitch-perfect, or it doesn't explain certain entities until much, much, much later in the tutorial along with complicated stuff I don't understand yet, and basically tells you to "just go with the flow, don't bother understanding them now". I'm not that type of learner, if I learn a new concept I HAVE to know everything about how it's used, how it works, how it's useful, etc. And in that one respect the tutorial leaves me craving for a knowledge supplement.
I have a few questions about some apparently simple features of Haskell (these questions are originated from the last section of a chapter called "Haskell Basics", which comes before "Elementary Haskell" and "Intermediate Haskell", so I consequently feel dumb for not understanding them immediately ). Just so that I'm on the same page as everyone so no one needs to do additional explaining, here IS what I know:
- what functions are
- how parameters work
- currying
- recursion (at least, simple forms of it)
- function typing
- abstract types
- simple pattern matching with things like tuples
- functions as first class values
- higher order functions
- variables
- apparently immutable
- simply stand-ins for equations, not same as imperative variables
- scoping within functions and function definitions
Here's a few questions:
What is an Action compared to a function? It seems as though they actually perform imperative actions like IO or the like, but still are treated mostly like functions, except can pass values to variables with the <- operator. What makes them special that they have their own operator to do this? what are do blocks exactly? all I know is that they combine Actions and end with expressions.
How can you treat variables as mutable? Is it true that there is no way to use mutable values in Haskell? In Tari's Haskell implementation of Merthese as an interpreter, he seemed to pass a value to a variable via <- from an action. Though he used recursion. Can someone explain why he was able to seemingly mutably affect the variable? Is it because he was affecting a variable local to that call of the function, and was redefined locally on the next recursive call?
Thanks in advance.
I have a few questions about some apparently simple features of Haskell (these questions are originated from the last section of a chapter called "Haskell Basics", which comes before "Elementary Haskell" and "Intermediate Haskell", so I consequently feel dumb for not understanding them immediately ). Just so that I'm on the same page as everyone so no one needs to do additional explaining, here IS what I know:
- what functions are
- how parameters work
- currying
- recursion (at least, simple forms of it)
- function typing
- abstract types
- simple pattern matching with things like tuples
- functions as first class values
- higher order functions
- variables
- apparently immutable
- simply stand-ins for equations, not same as imperative variables
- scoping within functions and function definitions
Here's a few questions:
What is an Action compared to a function? It seems as though they actually perform imperative actions like IO or the like, but still are treated mostly like functions, except can pass values to variables with the <- operator. What makes them special that they have their own operator to do this? what are do blocks exactly? all I know is that they combine Actions and end with expressions.
How can you treat variables as mutable? Is it true that there is no way to use mutable values in Haskell? In Tari's Haskell implementation of Merthese as an interpreter, he seemed to pass a value to a variable via <- from an action. Though he used recursion. Can someone explain why he was able to seemingly mutably affect the variable? Is it because he was affecting a variable local to that call of the function, and was redefined locally on the next recursive call?
Thanks in advance.