{"id":21073583,"url":"https://github.com/chouffe/nicta","last_synced_at":"2025-03-14T03:21:06.990Z","repository":{"id":148674419,"uuid":"79158056","full_name":"Chouffe/NICTA","owner":"Chouffe","description":"Functional Programming Class","archived":false,"fork":false,"pushed_at":"2017-02-11T20:47:19.000Z","size":3216,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T22:22:41.179Z","etag":null,"topics":["course","fp","haskell"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chouffe.png","metadata":{"files":{"readme":"README.markdown","changelog":"changelog","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-01-16T20:47:58.000Z","updated_at":"2017-02-28T05:47:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"d92a9068-1c6e-4b09-bde0-be422cfe7bfa","html_url":"https://github.com/Chouffe/NICTA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2FNICTA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2FNICTA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2FNICTA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chouffe%2FNICTA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chouffe","download_url":"https://codeload.github.com/Chouffe/NICTA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515511,"owners_count":20303258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["course","fp","haskell"],"created_at":"2024-11-19T19:01:17.819Z","updated_at":"2025-03-14T03:21:06.852Z","avatar_url":"https://github.com/Chouffe.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Functional Programming Course\n\n![NICTA](http://i.imgur.com/sMXB9XB.jpg)\n\n### Written by Tony Morris \u0026 Mark Hibberd for NICTA\n\n### With contributions from individuals (thanks!)\n\n#### Special note\n\nIf you have arrived here by https://github.com/tonymorris/course and you are\nlooking for the *exercises* (not the answers), please go to\nhttps://github.com/NICTA/course\n\n#### Introduction\n\nThe course is structured according to a linear progression and uses the Haskell\nprogramming language to learn programming concepts pertaining to functional\nprogramming.\n\nExercises are annotated with a comment containing the word \"Exercise.\" The existing code compiles, however answers have\nbeen replaced with a call to the Haskell `error` function and so the code will throw an exception if it is run. Some\nexercises contain tips, which are annotated with a preceding \"Tip:\". It is not necessary to adhere to tips. Tips are\nprovided for potential guidance, which may be discarded if you prefer a different path to a solution.\n\nThe exercises are designed in a way that requires personal guidance, so if you\nattempt it on your own and feel a little lost, this is normal. All the\ninstructions are not contained herein.\n\n### Getting Help\n\nThere are two mailing lists for asking questions. All questions are welcome,\nhowever, your first post might be moderated. This is simply to prevent spam.\n\n1. [[nicta-fp]](https://groups.google.com/forum/#!forum/nicta-fp) is a Google\n   Group for any queries related to functional programming. This mailing list is\n   owned by NICTA and is open to the public. Questions relating to this course\n   are most welcome here.\n\n2. [[haskell-exercises]](https://groups.google.com/forum/#!forum/haskell-exercises)\n   is a Google Group for queries related specifically to this NICTA funtional\n   programming course material. This mailing list is not owned by NICTA, but is\n   run by others who are keen to share ideas relating to the course.\n\n3. \\#scalaz [on Freenode](irc://irc.freenode.net/#scalaz) is an IRC channel that is operated\n   by others who are keen to share ideas relating to functional programming in\n   general. Most of the participants of this channel have completed the NICTA\n   functional programming course to some extent. They are in various timezones\n   and share a passion for functional programming, so may be able to provide\n   relatively quick assistance with questions.\n\n4. \\#nicta-course [on Freenode](irc://irc.freenode.net/#nicta-course) is an IRC channel that\n   is operated by others who are going through this course material on their\n   own time and effort.\n\n### Getting Started\n\n1. Install the Glasgow Haskell Compiler (GHC) version 7.6 or higher.\n\n2. Change to the directory containing this document.\n\n3. Execute the command `ghci`, which will compile and load all the source code.\n   You may need to set permissions on the root directory and the ghci configuration\n   file, `chmod 600 .ghci ./`.\n\n   \u003e stack exec ghci\n\n4. Inspect the introductory modules to get a feel for Haskell's syntax, then move\n   on to the exercises starting with `Course.List`. The [Progression](#progression)\n   section of this document lists the recommended order in which to attempt the exercises.\n\n5. Edit a source file to a proposed solution to an exercise. At the `ghci`\n   prompt, issue the command `:reload`. This will compile your solution and\n   reload it in the GHC interpreter. You may use `:r` for short.\n\n### Tips after having started\n\n1. Some questions take a particular form. These are called *WTF questions*. WTF\n   questions are those of this form or similar:\n  * What does ____ mean?\n  * What does the ____ function mean?\n  * What is a ____ ?\n  * Where did ____ come from ?\n  * What is the structure of ____ ?\n\n  They are all answerable with the `:info` command. For example, suppose you\n  have the question, \"What does the `swiggletwoop` function mean?\" You may\n  answer this at GHCi with:\n\n  `\u003e :info swiggletwoop`\n\n  You may also use `:i` for short.\n\n2. Functional Programming techniques rely heavily on types. This reliance may\n   feel foreign at first, however, it is an important part of this course. If\n   you wish to know the type of an expression or value, use `:type`. For\n   example,\n\n   `\u003e :type reverse`\n\n   `List t -\u003e List t`\n\n   This tells you that the `reverse` function takes a list of elements of some\n   arbitrary type (`t`) and returns a list of elements of that same type. Try\n   it.\n\n   You may also use `:t` for short.\n\n3. GHCi has TAB-completion. For example you might type the following:\n\n   `\u003e :type rev`\n\n   Now hit the TAB key. If there is only one function in scope that begins with\n   the characters `rev`, then that name will auto-complete. Try it. This\n   completion is context-sensitive. For example, it doesn't make sense to ask\n   for the type of a data type itself, so data type names will not auto-complete\n   in that context, however, if you ask for `:info`, then they are included in\n   that context. Be aware of this when you use auto-complete.\n\n   This also works for file names:\n\n   `\u003e readFile \"/etc/pas\"`\n\n   Now hit the TAB key. If there is only one existing filename on a path that\n   begins with `/etc/pas`, then that name will auto-complete. Try it.\n\n   If there is more than one identifier that can complete, hit TAB twice\n   quickly. This will present you with your options to complete.\n\n4. Follow the types.\n\n   You may find yourself in a position of being unsure how to proceed for a\n   given exercise. You are encouraged to adopt a different perspective. Instead\n   of asking how to proceed, ask how you might proceed while adhering to the\n   guideline provided by the types for the exercise at hand.\n\n   It is possible to follow the types without achieving the desired goal,\n   however, this is reasonably unlikely at the start. As you become more reliant\n   on following the types, you will develop more trust in the potential paths\n   that they can take you, including identification of false paths.\n\n   Your instructor must guide you where types fall short, but you should also\n   take the first step. Do it.\n\n#### Running the tests\n\nSome exercises include examples and properties, which appear in a comment above\nthe code for that exercise. Examples begin with `\u003e\u003e\u003e` while properties begin\nwith `prop\u003e`.\n\nThe solution to the exercise must satisfy these tests. You can check if you have\nsatisfied all tests with cabal-install and doctest. From the base directory of\nthis source code:\n\n    \u003e cabal update\n    \u003e cabal install cabal-install\n    \u003e cabal install --only-dependencies\n    \u003e cabal configure --enable-tests\n    \u003e cabal build\n    \u003e cabal test\n\nAlternatively, you may run the tests in a single source file by using `doctest`\nexplicitly. From the base directory of this source code:\n\n    \u003e doctest -isrc -Wall -fno-warn-type-defaults \u003cfilename.hs\u003e\n\nNote: There is a [bug in GHC 7.4.1](http://ghc.haskell.org/trac/ghc/ticket/5820)\nwhere for some configurations, running the tests will cause an unjustified\ncompiler error.\n\nWith stack, you can run a specific file with the following command:\n\n    \u003e stack exec doctest \u003cpath/filename.hs\u003e\n\n### Progression\n\nIt is recommended to perform some exercises before others. The first step is to\ninspect the introduction modules.\n\n* `Course.Id`\n* `Course.Optional`\n* `Course.Validation`\n\nThey contain examples of data structures and Haskell syntax. They do not contain\nexercises and exist to provide a cursory examination of Haskell syntax. The next\nstep is to complete the exercises in `Course.List`.\n\nAfter this, the following progression of modules is recommended:\n\n* `Course.Functor`\n* `Course.Applicative`\n* `Course.Monad` (please see [this issue](https://github.com/NICTA/course/issues/118))\n* `Course.FileIO`\n* `Course.State`\n* `Course.StateT`\n* `Course.Extend`\n* `Course.Comonad`\n* `Course.Compose`\n* `Course.Traversable`\n* `Course.ListZipper`\n* `Course.Parser` *(see also `Course.Person` for the parsing rules)*\n* `Course.MoreParser`\n* `Course.JsonParser`\n* `Course.Interactive`\n* `Course.Anagrams`\n* `Course.FastAnagrams`\n* `Course.Cheque`\n\nDuring this progression, it is often the case that some exercises are abandoned\ndue to time constraints and the benefit of completing some exercises over\nothers. For example, in the progression, `Course.Functor` to `Course.Monad`, the\nexercises repeat a similar theme. Instead, a participant may wish to do\ndifferent exercises, such as `Course.Parser`. In this case, the remaining\nanswers are filled out, so that progress on to `Course.Parser` can begin\n(which depends on correct answers up to `Course.Monad`). It is recommended to\ntake this deviation if it is felt that there is more reward in doing so.\n\nAnswers for the exercises can be found here:\n[https://github.com/tonymorris/course](https://github.com/tonymorris/course)\n\nAfter these are completed, complete the exercises in the `projects` directory.\n\n### Leksah\n\nIf you choose to use the [Leksah IDE for Haskell](http://leksah.org/), the\nfollowing tips are recommended:\n\n* Clone the git repo use Package -\u003e Add to add course.cabal.\n* Click on the green tick on the toolbar to include `cabal test`\n  in each build and list the failures in the Errors pane.\n* Choose Package -\u003e Configure to make sure `--enable-tests`\n  is used (just building may cause cabal to configure without).\n* Ctrl + B to build (Command + B on OS X).\n* The test failures should show up in Panes -\u003e Errors.\n* Pane -\u003e Log often has useful error messages.\n* Ctrl + J (Command + J on OS X) selects the next item in\n  Errors pane and goes to it in the source (hold down Shift\n  to go to previous item).\n* Ctrl + Enter on a line starting \"-- \u003e\u003e\u003e\" will run the\n  selected expression in GHCi (Ctrl + Enter on OS X too).\n  The output goes to Panes -\u003e Log and Panes -\u003e Output.\n* The last GHCi expression is reevaluated after each :reload\n  triggered by changes in the code.\n* Uncheck Debug -\u003e GHCi when you are done with GHCi and\n  Leksah will go back to running cabal build and cabal test\n  instead.\n\n### Introducing Haskell\n\nThis section is a guide for the instructor to introduce Haskell syntax. Each of\nthese points should be covered before attempting the exercises.\n\n* values, assignment\n* type signatures `::` reads as *has the type*\n  * The `-\u003e` in a type signature is *right-associative*\n* functions are values\n* functions take arguments\n  * functions take *only one argument* but we approximate without spoken\n    language\n  * functions can be declared inline using *lambda expressions*\n  * the `\\` symbol in a lambda expression denotes a Greek lambda\n* operators, beginning with non-alpha character, are in infix position by\n  default\n  * use in prefix position by surrounding with *(parentheses)*\n* regular identifiers, beginning with alpha character, are in prefix position by\n  default\n  * use in infix position by surrounding with ``backticks``\n* polymorphism\n  * type variables *always* start with a lower-case character\n* data types, declared using the `data` keyword\n  * following the `data` keyword is the *data type name*\n  * following the data type name are zero of more type variables\n  * then `=` sign\n  * data types have zero or more constructors\n    * data type constructors start with an upper-case character, or colon `(:)`\n  * following each constructor is a list of zero or more *constructor arguments*\n  * between each constructor is a pipe symbol `(|)`\n  * the `deriving` keyword gives us default implementations for some functions\n    on that data type\n  * when constructors appear on the left side of `=` we are *pattern-matching*\n  * when constructors appear on the right side of `=` we are *constructing*\n* type-classes\n\n### References\n\n* [The Haskell `error` function](http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:error)\n\n* [Glasgow Haskell Compiler](http://haskell.org/ghc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchouffe%2Fnicta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchouffe%2Fnicta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchouffe%2Fnicta/lists"}