<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.sw4sd.com/hasksheet/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://www.sw4sd.com/hasksheet/feed.php">
        <title>HaskSheet - codesnippets</title>
        <description></description>
        <link>https://www.sw4sd.com/hasksheet/</link>
        <image rdf:resource="https://www.sw4sd.com/hasksheet/lib/exe/fetch.php?media=wiki:dokuwiki.svg" />
       <dc:date>2026-04-17T08:05:29+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:accumulatingwithinmonadiccontextswithoutfolds&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:applicative&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:avoidconflictprelude&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:bindingandpatternmatching&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:codingconventions&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:compositionoperator&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:datastructuresfromsymboltrees&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:debugging&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:either&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:equivalentfunctioncompositions&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:filesystemioandstreams&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:firsthaskellprogram&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:flexibleinstances&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:fnowarnmissingsignatures&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:fnowarnorphans&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:folds&amp;rev=1759877283&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:ghcextensions&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:haddockexamples&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:hint&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:letandwhereconstructs&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:listcomprehension&amp;rev=1759877283&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:minimalcompletedefinition&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:monads&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:octets&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:parametrictypeforanintermediatevaluewhencombiningfunctions&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:patternmatching&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:prelude&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:randomvalues&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:recordsyntax&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:scans&amp;rev=1759877283&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:statefuldecoder&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:statemonads&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:templatehaskell&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:testingconventions&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:twopagesgenericparser&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typeapplications&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typeclasses&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typedefaulting&amp;rev=1759877285&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typesynonyminstances&amp;rev=1759877284&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:verificationandvalidation&amp;rev=1759877285&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://www.sw4sd.com/hasksheet/lib/exe/fetch.php?media=wiki:dokuwiki.svg">
        <title>HaskSheet</title>
        <link>https://www.sw4sd.com/hasksheet/</link>
        <url>https://www.sw4sd.com/hasksheet/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
    </image>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:accumulatingwithinmonadiccontextswithoutfolds&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>accumulatingwithinmonadiccontextswithoutfolds</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:accumulatingwithinmonadiccontextswithoutfolds&amp;rev=1759877284&amp;do=diff</link>
        <description>Accumulating within monadic contexts without folds

	*  

{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore &quot;Use void&quot; #-}
{-# HLINT ignore &quot;Use map&quot; #-}
{-# HLINT ignore &quot;Use foldl&quot; #-}

main :: IO ()
main =
    do
        print (f1a [3, 2, 6, 8])
        f1b [3, 2, 6, 8]
        f1c [3, 2, 6, 8] &gt;&gt;= print &gt;&gt; return ()
        print (f2a [] [3, 2, 6, 8])
        f2b [3, 2, 6, 8]
        f2c [] [3, 2, 6, 8] &gt;&gt; return ()

f1a :: [Int] -&gt; [Int]
f1a [] = []
f1a (n:rln) = (n + 1) : f1a …</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:applicative&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>applicative</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:applicative&amp;rev=1759877284&amp;do=diff</link>
        <description>Applicative

	*  - to be written -
	*  ...

✎</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:avoidconflictprelude&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>avoidconflictprelude</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:avoidconflictprelude&amp;rev=1759877284&amp;do=diff</link>
        <description>Avoiding name conflict with Prelude

The avoidance of prelude may make sense for the following reasons:

	*  reprogramming prelude functions to understand what it does
	*  reprogramming prelude functions to create improved versions
	*  avoiding conflicts with same name</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:bindingandpatternmatching&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>bindingandpatternmatching</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:bindingandpatternmatching&amp;rev=1759877285&amp;do=diff</link>
        <description>Binding and pattern matching

A binding binds a name or even several names with a function definition.

In Haskell, a binding is defined by symbol “=” whereas

	*  on the left hand side
		*  the function name and its parameters 
		*  or a pattern is given,</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:codingconventions&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>codingconventions</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:codingconventions&amp;rev=1759877285&amp;do=diff</link>
        <description>Coding conventions

	*  Derived from
		*  Haskell - Programming guidelines
		*  Haskell Style Guide

	*  Cross-link
		*  Haddock examples


General rules

Line length

For source code, the line length is up to 80 characters, at the maximum.

	*  Example: 

------------------------------------------------------------------------------ |---...

...

instance Formatting a =&gt; Formatting (Ds.Tree a) where
    format t = format&#039; (Indent []) t where
        format&#039; :: Formatting a =&gt; Indent -&gt; (Ds.Tree…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:compositionoperator&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>compositionoperator</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:compositionoperator&amp;rev=1759877285&amp;do=diff</link>
        <description>Composition operator

	*  composition operator is “.”
	*  type: (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
	*  takes two functions as parameter and combines the functions
		*  first function is applied to the result of the second function

	*  example:

import qualified Data.Char as Ch (ord)

main :: IO ()
main = 
    do
        print $ f3 &#039;a&#039;
        print $ f4 &#039;a&#039;

f1 :: Char -&gt; Integer
f1 ch = toInteger $ Ch.ord(ch)

f2 :: Integer -&gt; Double
f2 n = fromIntegral n :: Double

f3 :: Char -&gt; Double
f3 = f2 . …</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:datastructuresfromsymboltrees&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>datastructuresfromsymboltrees</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:datastructuresfromsymboltrees&amp;rev=1759877284&amp;do=diff</link>
        <description>Creating data structures from symbol trees

	*  example
		*  data structures for
			*   symbol tree
				*  with Terminal Chars as leafs

			*  container Construction as monadic class and instances
				*  error handling

			*  types for standard Construction instances</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:debugging&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>debugging</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:debugging&amp;rev=1759877285&amp;do=diff</link>
        <description>Debugging

Example with trace


module Main where

import Debug.Trace (trace)

main :: IO ()
main = do
    putStrLn $ reverse&#039; &quot;1234abcd&quot;

reverse&#039; :: Show a =&gt; [a] -&gt; [a]
reverse&#039; l = rev l []
    where
        rev [] acc = acc
        rev (e:r) acc = trace (show acc) (rev r (e : acc))</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:either&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>either</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:either&amp;rev=1759877285&amp;do=diff</link>
        <description>Either

	*  example code

main :: IO ()
main =
    do
        print $ f &quot;&quot;
        print $ f &quot;2&quot;
        print $ f &quot;23&quot;
        print $ f &quot;235&quot;
        print $ f &quot;2345&quot;
        print $ f &quot;2345a&quot;
        print $ f &quot;a2345&quot;
        print $ f &quot;a&quot;
        print $ f &quot;1a&quot;
        print $ f &quot;a1&quot;

f :: String -&gt; Either String Int
f lch = f&#039; lch 0
    where
        f&#039; :: String -&gt; Int -&gt; Either String Int
        f&#039; [] niAccu = Left &quot;empty&quot;
        f&#039; [ch] niAccu = f&#039;&#039; ch &gt;&gt;= (\ni -&gt; return ((niAccu * 10)…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:equivalentfunctioncompositions&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>equivalentfunctioncompositions</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:equivalentfunctioncompositions&amp;rev=1759877285&amp;do=diff</link>
        <description>Equivalent function compositions

	*  assertion: f1 (f2 . f3) equals (f1 . (f2 . )) f3
		*  example code:

main :: IO ()
main = 
    do
        print $ f f1&#039; f2&#039; f3&#039; 6.4
        print $ f&#039; f1&#039; f2&#039; f3&#039; 6.4
        print $ f&#039;&#039; f1&#039; f2&#039; f3&#039; 6.4

f :: ((Integer -&gt; String) -&gt; Double -&gt; [String]) -&gt; (Int -&gt; String) -&gt; (Integer -&gt; Int) -&gt;  Double -&gt; [String]
f f1 f2 f3 x&#039; = f1 (f2 . f3) x&#039;

f&#039; :: ((Integer -&gt; String) -&gt; Double -&gt; [String]) -&gt; (Int -&gt; String) -&gt; (Integer -&gt; Int) -&gt;  Double -&gt; [String]
f&#039;…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:filesystemioandstreams&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>filesystemioandstreams</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:filesystemioandstreams&amp;rev=1759877284&amp;do=diff</link>
        <description>Filesystem IO and streams

	* example:
		*  code, module FileSystem

{-|
Description : is to provides a generalised, abstract, and save interface to the files system.
Copyright   : (c) Jörg K.-H. W. Brüggmann, 2021
License     : CC0 1.0 Universal
Maintainer  : ...@...
Stability   : experimental
Portability : POSIX

* traits:

    * abstractions:

        * uniform types for identification of input and output streams (&#039;Inp&#039;, &#039;Out&#039;)

        * higher order functions encapsulated in data types (&#039;Da…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:firsthaskellprogram&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>firsthaskellprogram</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:firsthaskellprogram&amp;rev=1759877285&amp;do=diff</link>
        <description>First Haskell programs

	*  main function with output, as a complete code example
		*  compiles, error and warning free, with compiler: GHC 8.10.4, using compiler option -Wall
		*  

main :: IO ()
main = print &#039;x&#039;




	*  executes with the following output:</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:flexibleinstances&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>flexibleinstances</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:flexibleinstances&amp;rev=1759877285&amp;do=diff</link>
        <description>{-# LANGUAGE FlexibleInstances #-}

	*  allows to implement instances that are of form (T a1 ... an) where a1 ... an are particlar types (not type variables)
		*  [Double] instead of [a]

	*  implies the application of extension TypeSynonymInstances 
	*  example:
		*  code:</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:fnowarnmissingsignatures&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>fnowarnmissingsignatures</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:fnowarnmissingsignatures&amp;rev=1759877284&amp;do=diff</link>
        <description>{-# OPTIONS_GHC -fno-warn-missing-signatures #-}

	*  Prevents warnings of top level functions which have no type signature.
	*  NOTE: For better readability, sometimes it makes sense not to declate the type of top level functions and letting the compiler to infer the type.</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:fnowarnorphans&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>fnowarnorphans</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:fnowarnorphans&amp;rev=1759877284&amp;do=diff</link>
        <description>{-# OPTIONS_GHC -fno-warn-orphans #-}

	*  prevents warnings of orphan instance, meaning:
		*  instance declaration of a type is not declared in the module of the class

	*  NOTE: Orphan instances may be useful.
		*  see also Haskell wiki - Orphan instance

	*  NOTE: The purpose of the examples here is only to demonstrate the impact on the compiler. The examples may not make sense as a use case of type classes.</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:folds&amp;rev=1759877283&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:03+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>folds</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:folds&amp;rev=1759877283&amp;do=diff</link>
        <description>Folds

	*  inspired by Haskell wiki - Fold
	*  fold functions are used to fold lists
		*  folding means combining list elements

	*  fold functions take at least the following parameters:
		*  a function that combines two elements of the list
		*  the list of elements to be combined</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:ghcextensions&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>ghcextensions</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:ghcextensions&amp;rev=1759877284&amp;do=diff</link>
        <description></description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:haddockexamples&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>haddockexamples</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:haddockexamples&amp;rev=1759877285&amp;do=diff</link>
        <description>Haddock examples

Markups

Paragraphs

One or more blank lines separates two paragraphs in a documentation comment.

Special characters

The following characters have special meanings in documentation comments: \, /, &#039;, `, “, @, &lt;. To insert a literal occurrence of one of these special characters, precede it with a backslash (\).</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:hint&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>hint</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:hint&amp;rev=1759877284&amp;do=diff</link>
        <description>Interpreted Haskell code by package hint

	*  Hint is a package containing a Haskell interpreter built on top of the GHC API.
	*  example, modified from here, creates a source code file, interprets it and finally deletes it 

import Data.List

import qualified Control.Monad as M
import qualified Language.Haskell.Interpreter as Itpr
import qualified System.Directory as Dir
import qualified FileSystem as FS

main :: IO ()
main = 
    do
        Dir.setCurrentDirectory &quot;app&quot;
        createSomeModul…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:letandwhereconstructs&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>letandwhereconstructs</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:letandwhereconstructs&amp;rev=1759877284&amp;do=diff</link>
        <description>Let and where constructs

Hard differences

Inside expression

	*  let constructs are legal
		*  example code:

main = print (1 + (let i = 10 in 2 * i + 1))



	*  where constructs are ilegal
		*  example code:

main = print (1 + (2 * i + 1 where i = 10))</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:listcomprehension&amp;rev=1759877283&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:03+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>listcomprehension</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:listcomprehension&amp;rev=1759877283&amp;do=diff</link>
        <description>List comprehension

	*  syntactic sugar to apply set operations to lists
	*  syntax := “[” output expression “|” variable / binding = input set “,” predicate “]”
	*  e.g. [ 1 / x | x &lt;- [-1, -0.75 .. 1], x /= 0 ]
		*  creates a list</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:minimalcompletedefinition&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>minimalcompletedefinition</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:minimalcompletedefinition&amp;rev=1759877285&amp;do=diff</link>
        <description>Annotation for a minimal complete definition

Format:

{-# MINIMAL function1 | function2 #-}

Minimal pragmas are boolean expressions. For instance, with | as logical OR, either definition of the above functions must be defined. Comma indicates logical AND where both definitions must be defined.</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:monads&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>monads</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:monads&amp;rev=1759877284&amp;do=diff</link>
        <description>Monads

Example 1a

	*  this example shows how alternative results (sum type, algebraic type, see type A, B and C in the example) can be handled and propagated in a computation by means of &#039;case&#039; / &#039;of&#039; constructions
	*  it works but it is quite some code</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:octets&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>octets</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:octets&amp;rev=1759877285&amp;do=diff</link>
        <description>Octets

	*  type class Octetable
		*  with type Octet, and Octets
		*  with instances for Word32, Char, Utf8Char, Integer, and Int

	*  example
		*  code, of module Octetable:

{-# LANGUAGE BinaryLiterals #-}

module Octetable
    (
        Octetable(..), 
        Octet, 
        Octets, 
        getOctets, 
        putOctets
    ) where
 
import qualified Data.Word as W
import qualified Data.Bits as Bts
import qualified Data.Char as Chr
import qualified System.IO as SysIo
import qualified Data.…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:parametrictypeforanintermediatevaluewhencombiningfunctions&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>parametrictypeforanintermediatevaluewhencombiningfunctions</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:parametrictypeforanintermediatevaluewhencombiningfunctions&amp;rev=1759877284&amp;do=diff</link>
        <description>Parametric type for an intermediate value when combining functions

	*  example with the folling problem(s):
		*  function buildNRender has an ambigious intermediate parametric type
		*  the type of buildNRender has no parametric type g involved at all</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:patternmatching&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>patternmatching</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:patternmatching&amp;rev=1759877285&amp;do=diff</link>
        <description>Pattern matching, again

There was already some pattern matching explained, in the context of bindings here. Here we explain pattern matching in other contexts, which are:

	*  function definitions
	*  list comprehensions
	*  do notations
	*  case constructs</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:prelude&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>prelude</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:prelude&amp;rev=1759877285&amp;do=diff</link>
        <description>Prelude

	*  see also Prelude overview

	*  Composition operator
	*  Folds
	*  Scans
	*  Applicative
	*  Monads
	*  State monads</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:randomvalues&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>randomvalues</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:randomvalues&amp;rev=1759877284&amp;do=diff</link>
        <description>Random values

	*  example
		*  code, module Main:

{-# OPTIONS_GHC -fno-warn-orphans #-}

import qualified Randomisable as Rnd

main :: IO ()
main = do
  prng0 &lt;- Rnd.newStdGen
  print $ processMyData ((Rnd.random prng0) :: MyData)

processMyData :: MyData -&gt; (MyData, MyData, MyData2, ScaleA)
processMyData (MyData prng0 nd1 nd2 mydt2) = 
    let
        (prng1, prng2, prng3, prng4, prng5) = Rnd.tplPrngSplit5 prng0
    in
        ((MyData prng1 nd1 nd2 mydt2), (MyData prng2 (Rnd.randomise prng3 …</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:recordsyntax&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>recordsyntax</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:recordsyntax&amp;rev=1759877284&amp;do=diff</link>
        <description>Record syntax

	*  algebraic sum type )1
	*  provides access functions
	*  fields in curly brackets, comma separated

	*  short example:
		*  

data MatrixCursor = MatrixCursor { rnRow :: Integer, rnCol :: Integer }




----------

)1 An algebraic sum type (see also</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:scans&amp;rev=1759877283&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:03+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>scans</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:scans&amp;rev=1759877283&amp;do=diff</link>
        <description>Scans

	*  example
		*  code:

main :: IO ()
main = do
    print $ scanl (\nAcc -&gt; \(_, n) -&gt; nAcc + n) (0 :: Integer) (zip &quot;halleluja&quot; [1..])


		*  executes, with output:

[0,1,3,6,10,15,21,28,36,45]




✎</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:statefuldecoder&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>statefuldecoder</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:statefuldecoder&amp;rev=1759877285&amp;do=diff</link>
        <description>Stateful decoder

	*  example
		*  code, module Main:

import qualified Control.Monad.State as S

import qualified Safer as Sfr

main :: IO ()
main = 
    do
        --                                                                                                          MyData
        --                     + - take the next 4 characters converted to Integer -------------------------------&gt;     4736
        --                    /      + - take the next 3 Integer -----------------------------…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:statemonads&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>statemonads</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:statemonads&amp;rev=1759877284&amp;do=diff</link>
        <description>State monads

	*  inspired by Brandon Simmons: The State Monad: A Tutorial for the Confused?

Control.Monad.State applied, input from list

	*  inspired from &lt;https://wiki.haskell.org/State_Monad&gt;
	*  example compiles warning free with
			*  compiler: GHC 8.10.4 using -Wall
			*  package: mtl-2.2.2

	*  example:
		*  

import qualified Control.Monad.State as S

main :: IO ()
main = 
    do
        print $ S.evalState (playGame &quot;abcaaacbbcabbab&quot;) startState
        print $ S.evalState playGame2 s…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:templatehaskell&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>templatehaskell</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:templatehaskell&amp;rev=1759877284&amp;do=diff</link>
        <description>TemplateHaskell

Creating code at compile time

	*  Example, creates a curry function for arbitrary large curry functions

module Curry
    (
        curryN
    ) where

import Control.Monad
import Language.Haskell.TH

curryN :: Int -&gt; Q Exp
curryN n = do
    f  &lt;- newName &quot;f&quot;
    xs &lt;- replicateM n (newName &quot;x&quot;)
    let args = map VarP (f:xs)
        ntup = TupE (map (pure . VarE) xs)
    return $ LamE args (AppE (VarE f) ntup)</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:testingconventions&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>testingconventions</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:testingconventions&amp;rev=1759877284&amp;do=diff</link>
        <description>Testing conventions

Setup with stack

package.yaml

	*  package.yaml: 

...

tests:
  Test4-test:
    main:                Spec.hs
    source-dirs:         test
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - Test4
    - tasty
    - tasty-quickcheck
    - tasty-hunit</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:twopagesgenericparser&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>twopagesgenericparser</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:twopagesgenericparser&amp;rev=1759877284&amp;do=diff</link>
        <description>A generic parser on two pages

	*  usage in a main program:

module Main where

import Parser

main :: IO ()
main =
    do
        putStrLn &quot;&quot;
        putStrLn &quot;parse \&quot;0\&quot; synNumber:&quot;
        putStr &quot;    &quot;; print $ parse &quot;0&quot; synNumber
        putStrLn &quot;&quot;
        putStrLn &quot;parse \&quot;2\&quot; synNumber&quot;
        putStr &quot;    &quot;; print $ parse &quot;2&quot; synNumber
        putStrLn &quot;&quot;
        putStrLn &quot;parse \&quot;90\&quot; synNumber&quot;
        putStr &quot;    &quot;; print $ parse &quot;90&quot; synNumber
        putStrLn &quot;&quot;
        putStrLn &quot;…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typeapplications&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>typeapplications</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typeapplications&amp;rev=1759877285&amp;do=diff</link>
        <description>{-# LANGUAGE TypeApplications #-}

	*  allows to specify types to apply
	*  example, without type application
		*  code:

module Main where

main :: IO ()
main = print (read &quot;123&quot;)

		*  compiles with error:

app\Main.hs:4:15: error:
    * Ambiguous type variable `a0&#039; arising from a use of `read&#039;
      prevents the constraint `(Read a0)&#039; from being solved.
      Probable fix: use a type annotation to specify what `a0&#039; should be.
      These potential instances exist:
        instance Read Orderi…</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typeclasses&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>typeclasses</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typeclasses&amp;rev=1759877284&amp;do=diff</link>
        <description>Type classes and its instances, and the deriving mechanism

	*  A type class (keyword: class) is a set of functions declarations that 
		*  can have generic default bindings, and 
		*  have instances (keyword: instance) with type specific bindings.</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typedefaulting&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>typedefaulting</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typedefaulting&amp;rev=1759877285&amp;do=diff</link>
        <description>Type defaulting

Stil not clear how this works:

	*  

module Main where

main :: IO ()
main = do
    print $ negate 4



Output:

	*  

-4



...or this:

	*  

module Main where

main :: IO ()
main = do
    print $ sin 3



Output:

	*  

0.1411200080598672</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typesynonyminstances&amp;rev=1759877284&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:04+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>typesynonyminstances</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:typesynonyminstances&amp;rev=1759877284&amp;do=diff</link>
        <description>{-# LANGUAGE TypeSynonymInstances #-}

	*  allows to use type synonyms as instances
	*  example:
		*  code:

main :: IO ()
main = print x1

class MyClass x where
    fMy :: x -&gt; x -&gt; x

type Speed = Double

instance MyClass Speed where
    fMy xA xB = xA + xB

x1 :: Speed
x1 = fMy 1.3 2.5</description>
    </item>
    <item rdf:about="https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:verificationandvalidation&amp;rev=1759877285&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-10-07T22:48:05+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>verificationandvalidation</title>
        <link>https://www.sw4sd.com/hasksheet/doku.php?id=codesnippets:verificationandvalidation&amp;rev=1759877285&amp;do=diff</link>
        <description>Verification and Validation Plan

The goals of this plan is to document all steps to release a product like “genc³” as an online-product aiming to satisfiy the endusers expectations regarding download, installation, use, and further information.</description>
    </item>
</rdf:RDF>
