CPSC449:   Programming languages paradigms
                    (Fall  2022, Tuesday/Thursday 4:00-5:15pm,  ENA 101)

Instructor: Robin Cockett (ICT 652)
                                  (Office hours: immediately after class or by appointment)


Introduction to Haskell and Prolog.
Functional programming in Haskell:
Functional syntax, pattern matching,
Evaluating a program by hand, lazy evaluation
Lists and list comprehension
Datatypes and higher-order programming
Structural induction
Classes and monads
Relation to \lambda-calculus
Logic programming in Prolog:
Predicates, rules, variables
Satisfying goals, unification
Evaluation of rules by hand, cuts
Relation to theorem proving

Why should you take this course? 

This is a required course ... why?

The course introduces two programming paradigms "logic programming" and "functional programming" which you might otherwise not meet.  Constructs from these paradigms have and continue to "leak" into other programming paradigms (such as declarative and object oriented etc.).  The functional paradigm particularly is seen as a major player in future programming language design.  This is for many reasons: 
LECTURE NOTES (as they become available):
  1. Weaving to programming (James Burke here and here a biased history!)
  2. Fibonacci fun (here)
  3. Scott's bottom and lazy evaluation (here)
  4. Hand evaluating a Haskell program (here)
  5. We LOVE lists! (here) [Part I]
  6. We really LOVE list! (here) [Part II]
  7. OK lists are not so great! (here)
  8. We don't love trees yet ... (here) [Part I]
  9. OK we still don't love trees ...  (here) [Part II]
  10. Structural induction (here)
  11. Matching on steroids! (here) [Part III]
  12. Collected notes on unification (here)
  13. This is an unlucky number ....
  14. Exceptions with monads (here)
  15. Monads here, monads there, and monads everywhere (here)
  16. The state monad and monadic I/0 (here)
  17. Hand evaluating a prolog program (here)
  18. Reversing and permutating (here)
  19. A puzzler (here)
  20. Lets go a searching (here)
  21. Introduction to definite clause grammars (here)
  22. Folds in Prolog ... (here)


  1. (Due 23th September) Starting exercise in Haskell here.  Use this template file for your solution (with this supporting file). You may submit it to gradescope.ca -- as many times as you wish before the deadline -- gradescope will automatically run test cases on your submission) (3%)
  2. (Due 7th October) More exercises in Haskell here. Use this template file for your solution, as for exercise 1 (with this supporting file) (8%)
  3. (Week starting 10th October) Lab. test (on-line) for Haskell (some sample questions here) (9%)
  4. ( Due 2nd December) Exercises in Prolog here. Use this template file for your solution (7%).
  5. (Erly December) Lab. test (on-line) for Prolog (sample questions here) (8%)

ASSIGNMENT (10% + bonus):

     (Due 28th October) Checkers in Haskell (here): legal moves and applying moves (5%) the AI will be due 4th Novemeber (5% bonus) for checkers competition (TBA on-line).  Note: to get an A/A+ in the course you must participate in these assignments.  We hold a checkers tournament (for getting into the class tourmanment there is a 5% bonus: winning or running up in the tournament is worth a another 5% bonus.

EXAMS (55%):

  1. November 4th: Midterm (on-line).  Some sample questions here. (20%)
  2. December: Final (on-line).  Some example questions for revision are here. (35%)

Please find the tutorial notes here ....

Si Zhang
Jared Pon
Haiyang He
Xi Wang


You are assumed to be a competent programmer, well-versed in both procedural and object-oriented programming (CPSC 219/233/235 or equivalents), having a firm grasp of fundamental data structures (CPSC 319/331), and possessing the mathematical maturity required for proving elementary mathematical assertions (PHIL 279/377 also useful are CPSC 313/351).


Each component of the course will be given a percentage grade. The Final Grade will be obtained by computing the weighted average of those percentages and then converting the weighted average to a final letter grade using roughly the conversion scheme below (the instructor reserves the right to curve the grading scheme!):

95-100% A+ 80-84% B+ 65-69% C+ 50-54% D+
90-94% A 75-79% B 60-64% C 40-49% D
85-89% A- 70-74% B- 55-59% C- 0-39% F


The exams, lab. exams, exercise, and assignments will be marked using gradescope.  To submit your work you will need an account in gradscope.ca: to create one, if you do not have one go to "gradescope.ca" and press the "sign up" button (the course entry code is on the D2L "content" tab). Please use your ucalgary email to sign up.  If you are enrolled in the course gradescope will automatically identify you as being in the course.  If you have problems contact your TA.

D2L will be used only for recording your marks: this webpage and gradescope will be used for setting up exercise, tests, and assignments.


Late policy: exercises are generally due on Fridays but submissions will continue to be accepted until the Monday.  However, these submissions recorded as a "late submission".  When assessing your final grade in the whole course, if you are on a grade boundary, this submission history will be considered.  Submissions after the Monday's will not be accepted. (Note: any updated time-lines, if required, will be announced in lectures and indicated on this page).

Academic integrity:

My main concern is that you should be learning in this class: if you are cheating you are not learning!  Furthermore, you may be setting an unfortunate trend for your future work habits. I regard it as an integral part of my job, as a teacher, to ensure that you approach your work with the right attitude and will muster all the resources at my disposal to achieve this.

When you hand in work to be graded you are saying that it is your work. For programs this means that you typed in the program, developed it, and debugged it yourself.   If you use routines from a book or another source you must clearly document your source.  Furthermore, before handing in some code, you should spend a moment to consider how you had arrived at that code.  If you realize that some of the code which should have been yours is not then this is the time to come and talk to me or the TA before you get into trouble.   This allows us to apportion credit appropriately.

Please recall that we are using electronic tools to mark your assignments: suspiciously similar answers may be automatically noticed (even if we really don't want to see it!).

Discuss the course material!  I strongly encourage you to discuss all aspect of the course material!  Form study groups for the exams.   Your peers are your best learning resource!  When you discuss programming projects do so "off line" and away from the terminals: a good idea is to do so on a blackboard which you clean carefully after the discussion.   The golden rule is: after you have finished such a discussion you must walk away only with what is in your head!

See the honesty in academics website here.

Enjoy the course.


  1. (Highly recommended) The Craft of Functional Programming.  Simon Thompson;
  2. (Recommended) Learn you a Haskell for the greater good. Miran Lipovaca (on line free text!)
  3. (Recommended) Programming in Prolog.  William Clocksin and Chrisopher Mellish
  4. (Recommended) Prolog Programming for Artificial Intelligence.  Ivan Bratko