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
Indentation style
(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 style === [[Haskell (programming language)|Haskell]] layout can make the placement of braces optional, although braces and semicolons are allowed in the language. <ref>{{cite web |url=https://www.haskell.org/onlinereport/lexemes.html |title=The Haskell 98 Report |access-date=3 March 2016 |website=haskell.org}}</ref> The two segments below are equally acceptable to the compiler: <syntaxhighlight lang=haskell> braceless = do text <- getContents let firstWord = head $ words text bigWord = map toUpper firstWord putStrLn bigWord braceful = do { text <- getContents ; let { firstWord = head $ words text ; bigWord = map toUpper firstWord } ; putStrLn bigWord } </syntaxhighlight> In Haskell, layout can replace braces. Usually the braces and semicolons are omitted for [[Procedural programming|procedural]] <code>do</code> sections and the program text in general, but the style is commonly used for lists, records and other syntactic elements made up of some pair of parentheses or braces, which are separated with commas or semicolons.<ref>{{cite web |url=http://learnyouahaskell.com/making-our-own-types-and-typeclasses |title=Making Our Own Types and Typeclasses |access-date=3 February 2016 |website=learnyouahaskell.com |last=Lipovača |first=Miran}}</ref> If code following the keywords <code>where</code>, <code>let</code>, or <code>of</code> omits braces and semicolons, then indentation is significant.<ref>Haskell Report 1.2 (1992), p.131 B.4 "Layout"</ref>
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)