Re: [Haskell-beginners] Actions v. Functions

For example, `main = do input <- getLine ...', where `getLine' is an action as distinguished from a function such as `main'. Other examples of actions in Haskell include `print', `putStrLn' and any process that reads from or writes to a file. Of course, the list of actions doesn't end there, though the examples here should answer your question. Sincerely, Matt At 21:44 19/10/2013, you wrote:
What do you mean by "action"?
Antoine
On Fri, Oct 18, 2013 at 9:26 PM, MJ Williams <mailto:matthewjwilliams101@gmail.commatthewjwilliams101@gmail.com> wrote: Hello What are the formal properties of an action? How does an action differ from a function? Sincerely, Matthew
_______________________________________________ Beginners mailing list mailto:Beginners@haskell.orgBeginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Matt,
Start with the Functorshttp://learnyouahaskell.com/functors-applicative-functors-and-monoidschapter
of LYAH and continue reading through the chapter on
Monads. http://learnyouahaskell.com/a-fistful-of-monads
Another very good resource is You Could Have Invented
Monadshttp://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
.
Arjun
On Sat, Oct 19, 2013 at 5:09 PM, MJ Williams
For example, `main = do input <- getLine ...', where `getLine' is an action as distinguished from a function such as `main'. Other examples of actions in Haskell include `print', `putStrLn' and any process that reads from or writes to a file. Of course, the list of actions doesn't end there, though the examples here should answer your question. Sincerely, Matt
At 21:44 19/10/2013, you wrote:
What do you mean by "action"?
Antoine
On Fri, Oct 18, 2013 at 9:26 PM, MJ Williams
wrote: Hello What are the formal properties of an action? How does an action differ from a function? Sincerely, Matthew _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Sat, Oct 19, 2013 at 5:09 PM, MJ Williams
For example, `main = do input <- getLine ...', where `getLine' is an action as distinguished from a function such as `main'. Other examples of actions in Haskell include `print', `putStrLn' and
Actions aren't so much a formal thing as a conceptual "handle" to help with understanding monads. In particular, what a particular action represents depends on the monad, and in some cases on the particular implementation (for example, an IO action in GHC is a partially applied function, but this is an implementation detail that does nothing to help you understand how to work with it). -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

An action in this sense is just a function of type `Monad m => a -> m b'
(or one where the monad is specified, like `a -> IO b'). This type
signature fully specifies the "formal properties" of an action and shows
that actions do not differ from functions: they are merely functions of a
certain type.
On Sat, Oct 19, 2013 at 3:23 PM, Brandon Allbery
On Sat, Oct 19, 2013 at 5:09 PM, MJ Williams < matthewjwilliams101@gmail.com> wrote:
For example, `main = do input <- getLine ...', where `getLine' is an action as distinguished from a function such as `main'. Other examples of actions in Haskell include `print', `putStrLn' and
Actions aren't so much a formal thing as a conceptual "handle" to help with understanding monads. In particular, what a particular action represents depends on the monad, and in some cases on the particular implementation (for example, an IO action in GHC is a partially applied function, but this is an implementation detail that does nothing to help you understand how to work with it).
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Best, Rein Henrichs http://reinh.com c: 503.784.0697

Rein Henrichs wrote:
An action in this sense is just a function of type `Monad m => a -> m b' (or one where the monad is specified, like `a -> IO b'). This type signature fully specifies the "formal properties" of an action and shows that actions do not differ from functions: they are merely functions of a certain type.
I generally use the word "action" to refer to values of type `IO a` (or another monad). A value of type `a -> IO b` would be a function that returns an action. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com

On Sat, Oct 19, 2013 at 07:03:22PM -0700, Rein Henrichs wrote:
An action in this sense is just a function of type `Monad m => a -> m b' (or one where the monad is specified, like `a -> IO b'). This type signature fully specifies the "formal properties" of an action and shows that actions do not differ from functions: they are merely functions of a certain type.
I do not think so. An action is any value of a monadic type Monad m => m a An action is just a computation in a monad. When executed, an action of type `Monad m => m a' performs a computation and returns a value of type `a'. The nature of the computation depends on the monad being considered. For instance, actions in the IO monad, when executed, interacts with the system (to do IO, for instance). Actions in the Maybe monad may fail or succeed. Actions in the Reader monad can access an environment carrying some information. For some monads, an action may be a function, like in the Reader, Writer and State monads. But that is not a requirement. Actions in the Maybe and list monads are not functions.
On Sat, Oct 19, 2013 at 3:23 PM, Brandon Allbery
wrote: On Sat, Oct 19, 2013 at 5:09 PM, MJ Williams < matthewjwilliams101@gmail.com> wrote:
For example, `main = do input <- getLine ...', where `getLine' is an action as distinguished from a function such as `main'. Other examples of actions in Haskell include `print', `putStrLn' and
getLine and main are both actions in the IO monad.
Actions aren't so much a formal thing as a conceptual "handle" to help with understanding monads. In particular, what a particular action represents depends on the monad, and in some cases on the particular implementation (for example, an IO action in GHC is a partially applied function, but this is an implementation detail that does nothing to help you understand how to work with it).
participants (6)
-
Arjun Comar
-
Brandon Allbery
-
Heinrich Apfelmus
-
José Romildo Malaquias
-
MJ Williams
-
Rein Henrichs