Please note: Submit only one .hs or a .lhs file for an exercise, and don't put anything into the comment box. Your solution doesn't have to be completely correct to earn credit, but it has to implement at least a partial solution, and it has to show that you tried to solve the problem. A minimum requirement is that your program compiles without errors. Put all non-working parts in comments.
Important: Only programs that compile without error will be considered and will receive credit!
data Decision a = Certain a | Choice [a]When two decisions are to be combined, a certain decision always trumps an uncertain one, but two certain decisions will be combined into one uncertain one. Two uncertain decisions remain uncertain while their arguments are concatenated.
half x | even x = Certain (x `div` 2)What is the outcome of the expression Certain 11 >>= half >>= half? Did you expect it? Explain why this result is obtained.
| otherwise = Choice [h,h+1] where h = x `div` 2
1. Introduction [pdf] (Version 03/29/17) [BinTree.hs] [RoseTree.hs] 2. Type Classes [pdf] (Version 04/11/17) [TypeClass.hs Table.hs] 3. Refactoring4. Monads [pdf] (Version 04/17/17) [pdf (alternative slides)]
Back to the table of contents
Back to the table of contents
Learn You a Haskell for Geat GoodThe definite source of (basic) Haskell wisdom is, however, the following book.
Haskell 98 Language and Libraries: The Revised ReportAnother good textbook resource is Simon Thompson's book on Haskell.
Edited by Simon Peyton Jones. Cambridge University Press, 2003.
Haskell: The Craft of Functional ProgrammingFinally, as background reading material for functional data structures, I recommend Chris Okasaki's book.
By Simon Thompson. Addison-Wesley, 3rd ed., 2011.
Purely functional data structuresI have placed all three books as a course reserve in the library.
By Chris Okasaki. Cambridge University Press, 1998.
We will mainly use the GHC interpreter, which is available on many different platforms.
NOTE: If you haven't taken CS 581, please talk to me before the class to see whether you are well enough prepared.
Back to the table of contents
last change: April 27, 2017 | Martin Erwig erwig@oregonstate.edu |