[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572317-105":53,"doc-detail-572317-en":126},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":119,"head_meta":121,"extra_data":123,"updated_unix":125},105,"en","haskell-cheat-sheet-basic-syntax-examples","Haskell Cheat Sheet - Basic Syntax - Examples","","Haskell Cheat Sheet provides a compact reference to core Haskell elements, focusing on syntax, reserved keywords, and common language constructs. It explains single- and multi-line comments, documentation-comment conventions, string and number representations, and typical enumeration patterns. It also covers list and tuple construction, the layout rule (indentation-driven scope), brace and semicolon usage, and practical guidance for formatting function and let bindings. The sheet includes illustrative code examples.",{"@graph":63,"@context":118},[64,80,101],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/haskell-cheat-sheet-basic-syntax-examples/572317/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/haskell-cheat-sheet-basic-syntax-examples/572317.png","ImageObject",442,249,{"name":88,"@type":89},"Lucas Martin","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":47},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114],{"name":105,"@type":106,"acceptedAnswer":107},"How do single-line and multi-line comments work in Haskell?","Question",{"text":108,"@type":109},"Single-line comments start with `--` and run to the end of the line. Multi-line comments use `{-` and `-}` and can be nested.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"What is the “layout” rule in Haskell?",{"text":113,"@type":109},"Haskell uses indentation to represent scope: spaces indicate structure and the compiler requires consistent indentation. When errors occur, indent more to match expected nesting.",{"name":115,"@type":106,"acceptedAnswer":116},"How are strings and newlines handled in Haskell?",{"text":117,"@type":109},"A string cannot contain actual newline characters; inserting one in the source is a syntax error. Newlines must be represented explicitly (e.g., using `\\n`), and a backslash can escape a newline in the source.","https://schema.org",{"og:url":78,"og:type":120,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":122,"canonical":78},"index,follow",{"doc_id":124,"site_id":56},572317,1792360002,{"code":4,"msg":5,"data":127},{"doc_id":124,"user_id":128,"nickname":88,"user_avatar":129,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":47,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":135,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":47},8796095360427,"https://ap-avatar.wpscdn.com/davatar_994ba38a5ba835b3df7d355c54d3ed8d","Haskell Cheat Sheet  \nThis cheat sheet lays out the fundamental elements of the Haskell language: syntax, keywordsand other elements. It is presented as both an executable Haskell ﬁle and a printable document. Load the source into your favorite interpreter to play with code samples shown.  \nBasic Syntax Comments  \nA single line comment starts with `--' and extends to the end of the line. Multi-line comments start with '{-' and extend to '-}' . Comments can be nested.  \nComments above function deﬁnitions should start with `{ - |' and those next to parameter types with ` - - ^' for compatibility with Haddock, a system for documenting Haskell code.  \nReserved Words  \nThe following words are reserved in Haskell. It is a syntax error to give a variable or a function oneof these names.  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \ncase class data deriving do  \nelse  \nif  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \nimport in infix  \ninfixl  \ninfixr  \ninstance let  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \n􀀏  \nof module newtype then  \ntype where  \nStrings  \n􀀏 \"abc\" – Unicode string, sugar for [✬a✬,✬b✬,✬c✬] .  \n􀀏 ✬a✬ – Single character.  \nMulti-line Strings Normally, it is a syntax error if a string has any actual newline characters. That is, this is a syntax error:  \nstring1 = \"My long  \nstring . \"  \nBackslashes (`\\') can “escape” a newline:  \nstring1 = \"My long \\  \n\\string . \"  \nThe area between the backslashes is ignored. Newlines in the string must be represented explicitly:  \nstring2 = \"My long \\n\\  \n\\string . \"  \nThat is, string1 evaluates to: My long string .  \nWhile string2 evaluates to:  \nMy long  \nstring .  \nNumbers  \n􀀏 1 – Integer or Floating point  \n􀀏 1 .0, 1e10 – Floating point  \n􀀏 1.– syntax error  \n􀀏 -1 – sugar for (negate 1)  \n􀀏 2-1 – sugar for ((-) 2 1)  \nEnumerations  \n􀀏 [1   10] – List of numbers – 1, 2, . . . , 10 .  \n􀀏 [100 ..] – Inﬁnite list of numbers – 100, 101, 102, . . . .  \n􀀏 [110 . . 100] – Empty list; ranges only go forwards.  \n􀀏 [0, -1 . .] – Negative integers.  \n􀀏 [-100 . .-110] – Syntax error; need [-100 . . -110] for negatives.  \n􀀏 [1,3   100], [-1,3   100] – List from 1 to  \n100 by 2, -1 to 100 by 4 .  \nIn fact, any value which is in the Enum class can be used:  \n􀀏 [✬a✬   ✬z✬] – List of characters – a, b,. . . , z.  \n􀀏 [1 .0, 1 .5   2] – [1 .0,1 .5,2 .0] .  \n􀀏 [UppercaseLetter . .] – List of GeneralCategory values (from Data.Char) .  \nLists & Tuples  \n􀀏 [] – Empty list.  \n􀀏 [1,2,3] – List of three numbers.  \n􀀏 1 : 2 : 3 : [] – Alternate way to write lists using “cons”(:) and “nil”([]) .  \n􀀏 \"abc\" – List of three characters (strings are lists) .  \n􀀏 ✬a✬ : ✬b✬ : ✬c✬ : [] – List of characters (same as \"abc\") .  \n􀀏 (1,\"a\") – 2-element tuple of a number anda string.  \n􀀏 (head, tail, 3, ✬a✬) – 4-element tuple of two functions, a number and a character.  \n“Layout” rule, braces and semi-colons.  \nHaskell can be written using braces and semicolons, just like C. However, no one does. Instead, the “layout” rule is used, where spaces represent scope. The general rule is: always indent. When the compiler complains, indent more.  \nBraces and semi-colons Semi-colons terminate an expression, and braces represent scope. They can be used after several keywords: where, let, do and of. They cannot be used when deﬁning a function body. For example, the below will not compile.  \nsquare2 x = { x * x; } However, this will work ﬁne:  \nsquare2 x = result  \nwhere { result = x * x; }  \nFunction Deﬁnition Indent the body at least one space from the function name:  \nsquare x =  \nx * x  \nUnless a where clause is present. In that case, indent the where clause at least one space from the function name and any function bodies at least one space from the where keyword:  \nsquare x =  \nx2  \nwhere x2 =  \nx * x  \nLet Indent the body of the let at least one space from the ﬁrst deﬁnition in the let. If let appears on its own line, the body of any deﬁnition must appear in the column after the let:  \nsquare x =  \nlet x2 =  \nx * x  \nin x2  \nAs can be seen above, the in keyword must also bein the ","cbCaipXuLmQkMkfN","https://ap.wps.com/l/cbCaipXuLmQkMkfN","pdf",156521,13,"English","# Basic Syntax Comments\n## Reserved Words and Keywords\n# Strings and Numbers\n## Enumerations\n# Lists & Tuples\n## Layout Rule and Indentation\n# Function Definition and Let\n## Case, Pattern Matching, Guards\n# Examples and Matching Order","[{\"question\":\"How do single-line and multi-line comments work in Haskell?\",\"answer\":\"Single-line comments start with `--` and run to the end of the line. Multi-line comments use `{-` and `-}` and can be nested.\"},{\"question\":\"What is the “layout” rule in Haskell?\",\"answer\":\"Haskell uses indentation to represent scope: spaces indicate structure and the compiler requires consistent indentation. When errors occur, indent more to match expected nesting.\"},{\"question\":\"How are strings and newlines handled in Haskell?\",\"answer\":\"A string cannot contain actual newline characters; inserting one in the source is a syntax error. Newlines must be represented explicitly (e.g., using `\\\\n`), and a backslash can escape a newline in the source.\"}]","Haskell Cheat Sheet - Basic Syntax - Examples | PDF",1791926715]