Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Entry point
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Haskell=== A [[Haskell (programming language)|Haskell]] program must contain a name <code>main</code> bound to a value of type <code>IO t</code>, for some type <code>t</code>;<ref>{{cite web |url=http://www.haskell.org/onlinereport/modules.html |title=The Haskell 98 Report: Modules |publisher=Haskell.org |access-date=2013-08-19 |archive-date=2013-08-19 |archive-url=https://web.archive.org/web/20130819042412/http://www.haskell.org/onlinereport/modules.html |url-status=live }}</ref> which is usually <code>IO ()</code>. <code>IO</code> is a [[monads in functional programming|monad]], which organizes [[Side effect (computer science)|side-effects]] in terms of [[purely functional programming|purely functional]] code.<ref>[http://geekrant.wordpress.com/2008/06/23/misconceptions/ Some Haskell Misconceptions: Idiomatic Code, Purity, Laziness, and IO] {{Webarchive|url=https://web.archive.org/web/20100727150353/http://geekrant.wordpress.com/2008/06/23/misconceptions/ |date=2010-07-27 }} β on Haskell's monadic IO></ref> The <code>main</code> value represents the side-effects-ful computation done by the program. The result of the computation represented by <code>main</code> is discarded; that is why <code>main</code> usually has type <code>IO ()</code>, which indicates that the type of the result of the computation is <code>()</code>, the [[unit type]], which contains no information. <syntaxhighlight lang="haskell"> main :: IO () main = putStrLn "Hello, World!" </syntaxhighlight> Command line arguments are not given to <code>main</code>; they must be fetched using another IO action, such as <code>[https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base-4.11.1.0/System-Environment.html#v%3AgetArgs System.Environment.getArgs]</code>.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)