[Haskell-beginners] Actions v. Functions

Rein Henrichs rein.henrichs at gmail.com
Sun Oct 20 02:03:22 UTC 2013


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 <allbery.b at gmail.com>wrote:

> On Sat, Oct 19, 2013 at 5:09 PM, MJ Williams <
> matthewjwilliams101 at 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 at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
Best,

Rein Henrichs
http://reinh.com
c: 503.784.0697
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131019/5cebfbeb/attachment.html>


More information about the Beginners mailing list