Difference between revisions of "Functional programming/cs"
(Created page with "== Cvičení ==") |
(Updating to match new version of source page) |
||
Line 16: | Line 16: | ||
===Způsob průběžné kontroly znalostí během semestru=== | ===Způsob průběžné kontroly znalostí během semestru=== | ||
Během cvičení budou studenti programovat zadané úkoly. Výsledky těchto úkolů budou důležitou součástí závěrečného hodnocení. Bude zadáno nejméně sedm hodnocených úkolů. Dále budou zadány dva menší projekty. | Během cvičení budou studenti programovat zadané úkoly. Výsledky těchto úkolů budou důležitou součástí závěrečného hodnocení. Bude zadáno nejméně sedm hodnocených úkolů. Dále budou zadány dva menší projekty. | ||
+ | |||
+ | == Software == | ||
+ | In our lectures, we will be using [https://www.haskell.org/downloads/#platform Haskell Platform] with [https://code.visualstudio.com/ Visual Studio Code]. For VS Code, we will be using two extensions: | ||
+ | *[https://marketplace.visualstudio.com/items?itemName=Vans.haskero Haskero] | ||
+ | *[https://marketplace.visualstudio.com/items?itemName=phoityne.phoityne-vscode Haskell GHCi Debug Adapter Phoityne] | ||
+ | |||
+ | === Installation guide Windows (single user) === | ||
+ | |||
+ | # Download and install Haskell platform from [https://www.haskell.org/platform/windows.html https://www.haskell.org/platform/windows.html] | ||
+ | #* Use default paths. Installer adds to system variable <code>PATH</code> a path to executable <code>stack.exe</code>. | ||
+ | # Download and install VS Code [https://code.visualstudio.com/#alt-downloads https://code.visualstudio.com/#alt-downloads] | ||
+ | # Open file <code>c:\sr\config.yaml</code> and add a line <pre>system-ghc : true</pre> | ||
+ | # Open <code>cmd</code> and type:<pre class="bash">stack install intero phoityne-vscode haskell-dap--system-ghc</pre> | ||
+ | #* Attribute <code>--system-ghc</code> is optional and redundant to previous step (it is the same setting, but global). | ||
+ | # Open VS Code and install extensions: | ||
+ | #* Haskero | ||
+ | #* Haskell GHCi Debug Adapter Phoityne | ||
+ | |||
+ | === Installation guide Windows (all users) === | ||
+ | This guide assumes, that there is on user, that prepares the development environment for other user. | ||
+ | <ol> | ||
+ | <li>Download and install Haskell platform from [https://www.haskell.org/platform/windows.html https://www.haskell.org/platform/windows.html] </li> | ||
+ | <li>* For <code>stack</code>, use a path accessible to all user (for example <code>c:\stack</code>). Installer adds to user variable <code>PATH</code> a path to executable <code>stack.exe</code>, and adds a new user variable <code>STACK_ROOT</code>. Move these values from user variables to system variables. | ||
+ | </li> | ||
+ | <li>Download and install VS Code [https://code.visualstudio.com/#alt-downloads https://code.visualstudio.com/#alt-downloads]. Use the system installer.</li> | ||
+ | <li>Open file <code>c:\sr\config.yaml</code> and add lines: | ||
+ | <pre> | ||
+ | system-ghc : true | ||
+ | skip-msys : true | ||
+ | </pre> | ||
+ | These settings save time and space on disk (it will not install GHC while installing packages and [https://www.msys2.org/ MSYS2] for every user). | ||
+ | </li> | ||
+ | <li>Open <code>cmd</code> and type:<pre class="bash">stack install intero phoityne-vscode haskell-dap</pre> | ||
+ | * It will generate some executable files to default location: <code>c:\Users\ -- YOUR NAME -- \AppData\Roaming\local\bin\</code> move them to the directory with <code>stack.exe</code>. | ||
+ | </li> | ||
+ | <li> Open VS Code and install extensions: | ||
+ | * Haskero | ||
+ | * Haskell GHCi Debug Adapter Phoityne | ||
+ | </li> | ||
+ | </ol> | ||
+ | === Installation guide Ubuntu (single users) === | ||
+ | <ol> | ||
+ | <li>Perform following commands: | ||
+ | <pre class="bash"> | ||
+ | sudo apt-get install haskell-platform | ||
+ | sudo apt-get install haskell-stack | ||
+ | sudo snap install code --classic | ||
+ | </pre> | ||
+ | * ''Optional step'' - Right now (August, 2019) Haskell Platform from Ubuntu repositories contains GHC 8.4.4. Stack current default resolver is lts-14.00. It requires GHC version 8.6.5. It will automatically download this version. To save disk space, you can generate stack global config (for example <code>stack path</code>) and change the global resolver in file <code>~/.stack/global-project/stack.yaml</code> to <code>lts-12.15</code>. Then open file <code>~/.stack/config.yaml</code> and add lines: | ||
+ | <pre> | ||
+ | system-ghc : true | ||
+ | skip-ghc-check: true | ||
+ | </pre> | ||
+ | </li> | ||
+ | <li> Continue with installation of required packages: | ||
+ | <pre class="bash"> | ||
+ | stack install intero phoityne-vscode haskell-dap | ||
+ | </pre></li> | ||
+ | <li> Open VS Code and install extensions: | ||
+ | * Haskero | ||
+ | * Haskell GHCi Debug Adapter Phoityne | ||
+ | </li> | ||
+ | </ol> | ||
+ | |||
+ | === Installation guide Ubuntu (all users) === | ||
+ | <ol> | ||
+ | <li> | ||
+ | Perform following commands: | ||
+ | <pre class="bash"> | ||
+ | sudo apt-get install haskell-platform | ||
+ | sudo apt-get install haskell-stack | ||
+ | sudo snap install code --classic | ||
+ | </pre> | ||
+ | </li> | ||
+ | <li>Create a directory that will be a stack root, it should be readable by all users (for example <code>/stack</code>).</li> | ||
+ | <li>Create a file <code>/etc/profile.d/stack.sh</code> with following line:<CODE>export STACK_ROOT=</CODE>''your stack root directory''</li> | ||
+ | <li>Create a file <code>/etc/stack/config.yaml</code> with following lines: | ||
+ | <pre> | ||
+ | skip-ghc-check: true | ||
+ | system-ghc: true | ||
+ | allow-different-user: true | ||
+ | </pre> | ||
+ | </li> | ||
+ | <li>Generate stack global config (for example <code>stack path</code>) and change the global resolver in file <code>$STACK_ROOT/global-project/stack.yaml</code> to <code>lts-12.15</code>.</li> | ||
+ | <li> Continue with installation of required packages: | ||
+ | <pre class="bash"> | ||
+ | stack install intero phoityne-vscode haskell-dap | ||
+ | </pre></li> | ||
+ | <li>It will produce some executable files to <code>~/.local/bin</code> copy them to: <code>/usr/local/bin</code> (or other ''search when executing'' location). | ||
+ | </li> | ||
+ | <li> Open VS Code and install extensions: | ||
+ | * Haskero | ||
+ | * Haskell GHCi Debug Adapter Phoityne | ||
+ | </li> | ||
+ | </ol> | ||
== Prezentace == | == Prezentace == | ||
<span id="presentations"></span> | <span id="presentations"></span> | ||
+ | <div class="mw-translate-fuzzy"> | ||
Presentations [[#presentations]] [[#top]] | Presentations [[#presentations]] [[#top]] | ||
+ | </div> | ||
+ | |||
+ | Schedule: | ||
+ | * Lecture 1: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
+ | * Lecture 2: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
+ | * Lecture 3: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
+ | * Lecture 4: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
+ | * Lecture 5: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
+ | * Lecture 6: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
+ | * Lecture 7: [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=1 Page 1] - [http://linedu.vsb.cz/~beh01/wiki_data/Functional%20programming.pdf#page=20 Page 20] | ||
== Cvičení == | == Cvičení == | ||
{{anchor|laboratories}} | {{anchor|laboratories}} | ||
+ | <div class="mw-translate-fuzzy"> | ||
* Lab 1 - [[#laboratories]] | * Lab 1 - [[#laboratories]] | ||
* Lab 2 - | * Lab 2 - | ||
+ | </div> |
Revision as of 08:32, 12 August 2019
Contents
Úvod
Předmět seznamuje s funkcionálním stylem programování. Zahrnuje základní vlastnosti funkcionálního programování, jako je programování bez vedlejších efektu, funkce jako hodnota prvního řádu, funkce vyšších řádů, rekurze, přizpůsobení, technika pattern matching nebo uzávěry funkcí. Rovněž kurz představuje vybrané datové struktury jako je seznam nebo strom a funkcionální styl práce s těmito strukturami. Jako programovací jazyk bude použit Haskell. Je to čistě funkcionální, staticky typovaný a líně vyhodnocovaný jazyk.
Cíle předmětu vyjádřené dosaženými dovednostmi a kompetencemi
Základním cílem předmětu bude dovednost zapsat jednoduché algoritmy pomocí funkcionálního stylu programování. Přesněji řečeno, studenti pochopí rekurzi a vybrané rekurzivní datové struktury, budou schopni využívat funkce vyššího řádu, budou schopni definovat funkce pomocí techniky pattern matching. Budou schopni používat mechanismus zapouzdření pro funkce jako jsou uzávěry či modulární rozhraní a správně rozumět proměnným a jejich lexikálnímu rozsahu platnosti v programech. Na praktické úrovni budou schopni zapsat tyto základní algoritmy v programovacím jazyce Haskell. Navíc budou schopni rozpoznat funkcionální styl programování, pochopí výhody a nevýhody tohoto stylu programování a budou schopni porovnat tento styl programování s jinými přístupy, jako je imperativní nebo objektově orientované programování.
Doporučená literatura
- Lipovaca M.:Learn You a Haskell for Great Good!: A Beginner's Guide (1st ed.). No Starch Press, San Francisco, CA, USA, 2011 - for free at: http://learnyouahaskell.com/
- O'Sullivan B., Goerzen J., Stewart D.: Real world Haskell, O'Reilly Media, Inc. 2008. ISBN:0596514980 - for free at: http://book.realworldhaskell.org/read/
- Thompson S.: The Haskell: The Craft of Functional Programming (3nd ed.). Addison-Wesley Professional, October 2, 2011, ISBN-10: 0201882957.
Způsob průběžné kontroly znalostí během semestru
Během cvičení budou studenti programovat zadané úkoly. Výsledky těchto úkolů budou důležitou součástí závěrečného hodnocení. Bude zadáno nejméně sedm hodnocených úkolů. Dále budou zadány dva menší projekty.
Software
In our lectures, we will be using Haskell Platform with Visual Studio Code. For VS Code, we will be using two extensions:
Installation guide Windows (single user)
- Download and install Haskell platform from https://www.haskell.org/platform/windows.html
- Use default paths. Installer adds to system variable
PATH
a path to executablestack.exe
.
- Use default paths. Installer adds to system variable
- Download and install VS Code https://code.visualstudio.com/#alt-downloads
- Open file
c:\sr\config.yaml
and add a linesystem-ghc : true
- Open
cmd
and type:stack install intero phoityne-vscode haskell-dap--system-ghc
- Attribute
--system-ghc
is optional and redundant to previous step (it is the same setting, but global).
- Attribute
- Open VS Code and install extensions:
- Haskero
- Haskell GHCi Debug Adapter Phoityne
Installation guide Windows (all users)
This guide assumes, that there is on user, that prepares the development environment for other user.
- Download and install Haskell platform from https://www.haskell.org/platform/windows.html
- * For
stack
, use a path accessible to all user (for examplec:\stack
). Installer adds to user variablePATH
a path to executablestack.exe
, and adds a new user variableSTACK_ROOT
. Move these values from user variables to system variables. - Download and install VS Code https://code.visualstudio.com/#alt-downloads. Use the system installer.
- Open file
c:\sr\config.yaml
and add lines:system-ghc : true skip-msys : true
These settings save time and space on disk (it will not install GHC while installing packages and MSYS2 for every user).
- Open
cmd
and type:stack install intero phoityne-vscode haskell-dap
- It will generate some executable files to default location:
c:\Users\ -- YOUR NAME -- \AppData\Roaming\local\bin\
move them to the directory withstack.exe
.
- It will generate some executable files to default location:
- Open VS Code and install extensions:
- Haskero
- Haskell GHCi Debug Adapter Phoityne
Installation guide Ubuntu (single users)
- Perform following commands:
sudo apt-get install haskell-platform sudo apt-get install haskell-stack sudo snap install code --classic
- Optional step - Right now (August, 2019) Haskell Platform from Ubuntu repositories contains GHC 8.4.4. Stack current default resolver is lts-14.00. It requires GHC version 8.6.5. It will automatically download this version. To save disk space, you can generate stack global config (for example
stack path
) and change the global resolver in file~/.stack/global-project/stack.yaml
tolts-12.15
. Then open file~/.stack/config.yaml
and add lines:
system-ghc : true skip-ghc-check: true
- Optional step - Right now (August, 2019) Haskell Platform from Ubuntu repositories contains GHC 8.4.4. Stack current default resolver is lts-14.00. It requires GHC version 8.6.5. It will automatically download this version. To save disk space, you can generate stack global config (for example
- Continue with installation of required packages:
stack install intero phoityne-vscode haskell-dap
- Open VS Code and install extensions:
- Haskero
- Haskell GHCi Debug Adapter Phoityne
Installation guide Ubuntu (all users)
-
Perform following commands:
sudo apt-get install haskell-platform sudo apt-get install haskell-stack sudo snap install code --classic
- Create a directory that will be a stack root, it should be readable by all users (for example
/stack
). - Create a file
/etc/profile.d/stack.sh
with following line:export STACK_ROOT=
your stack root directory - Create a file
/etc/stack/config.yaml
with following lines:skip-ghc-check: true system-ghc: true allow-different-user: true
- Generate stack global config (for example
stack path
) and change the global resolver in file$STACK_ROOT/global-project/stack.yaml
tolts-12.15
. - Continue with installation of required packages:
stack install intero phoityne-vscode haskell-dap
- It will produce some executable files to
~/.local/bin
copy them to:/usr/local/bin
(or other search when executing location). - Open VS Code and install extensions:
- Haskero
- Haskell GHCi Debug Adapter Phoityne
Prezentace
Presentations #presentations #top
Schedule:
- Lecture 1: Page 1 - Page 20
- Lecture 2: Page 1 - Page 20
- Lecture 3: Page 1 - Page 20
- Lecture 4: Page 1 - Page 20
- Lecture 5: Page 1 - Page 20
- Lecture 6: Page 1 - Page 20
- Lecture 7: Page 1 - Page 20
Cvičení
- Lab 1 - #laboratories
- Lab 2 -