Skip to content

Latest commit

 

History

History
249 lines (220 loc) · 11.2 KB

File metadata and controls

249 lines (220 loc) · 11.2 KB

* cis194 Brent Yorgey BFPG talks based n Yorgey course

Homework 1:

Week 2: Algebraic Data Types ( html, lhs )

Speaker: Nick Partridge Video: http://vimeo.com/90515452 Homework 2: [error.log, sample.log, Log.hs ]

Week 3: Recursion patterns, polymorphism, and the Prelude ( html, lhs )

Speaker: Matthew Brecknell Video: http://vimeo.com/92976563 Homework 3:

Week 4: Higher-order programming and type inference ( html, lhs )

Speaker: Christopher McKay Video: http://vimeo.com/97015597 Homework 4:

Week 5: More polymorphism and type classes ( html, lhs )

Speaker: Fraser Tweedale Video: http://vimeo.com/99034519 Homework 5: [ExprT.hs, Parser.hs, StackVM.hs ]

Week 6: Lazy evaluation ( html, lhs )

Speaker: Ben Kolera Video: http://vimeo.com/101396464 Homework 6:

Week 7: Folds and monoids ( html, lhs )

Speaker: George Wilson github George Wilson Video: http://vimeo.com/105047461 Slides: https://github.com/gwils/bfpg-slides-140826 Homework 7: [Editor.hs, Buffer.hs, Sized.hs, StringBuffer.hs, StringBufEditor.hs, carol.txt ]

Week 8: IO ( html, lhs )

Speaker: Jamie Cook Video: http://vimeo.com/107081622 Homework 8: [Employee.hs, company.txt ]

Week 9: Functors ( html, lhs )

Speaker: Brenton Alker Video: http://vimeo.com/110492903 Homework 9: due never (no HW this week).

Week 10: Applicative functors (part 1) ( html, lhs )

Speaker: Sean Chalmers (week 10 & 11) Video: http://vimeo.com/112814183 Homework 10: [AParser.hs ]

Week 11: Applicative functors (part 2) ( html, lhs )

Speaker: Sean Chalmers (week 10 & 11) Video: http://vimeo.com/112814183 Homework 11: [AParser.hs, SExpr.hs ]

Week 12: Monads ( html, lhs )

Speaker: Matt Peddie Video: http://talks.bfpg.org/talks/2015-02-24.monads.html Homework 12: [Risk.hs ]

Testing in haskell

Add doctesting

Add HUnit testing

HSpec testing

learn testy

Rower of hanoi problem

research the papaer “functional pearl: la tour d’hanoi”

code and run the approach in the papaer “functional pearl: la tour d’hanoi”

1. Introduction to Haskell - BFPG talk based on BYorgey course Haskell is lazy, functional language. Haskell is
  1. Functional
    1. functions are first-class
    2. evaluating expressions rather than executing instructions.
  2. Pure
    • Haskell expression are always referentially transparent
      • No mutations! Everything is immutable
      • No side effcts.
      • same input -> same output allways
    • Purity mean also
      • Equational reasoning and refactoring: In Haskell one can always “replace equals by equals”, just like you learned in algebra class.
      • Parallelism: Evaluating expressions in parallel is easy when they are guaranteed not to affect one another.
      • Fewer headaches: Simply put, unrestricted effects and action-at-a-distance makes for programs that are hard to debug, maintain, and reason about.
  3. Lazy expressions are not evaluated until their results are actually needed
    • It is easy to define a new control structure just by defining a function.
    • It is possible to define and work with infinite data structures.
    • It enables a more compositional programming style (see wholemeal programming below).
    • One major downside, however, is that reasoning about time and space usage becomes much more complicated!
  4. Statically typed

Homework 1: CCard Number, Hanoi

Week 2: Working with Lists

3. Recursion patterns, polymorphism, and the Prelude - BFPG talk based on BYorgey course

Difference lists video from author

Homework 2: Scrabble

file:../../CIS194/reisenberg/homework/haskell/src/Hw02.hs::— Exercise 7. 2. Algebraic data types - BFPG talk based on BYorgey course
  • Algebraic data types in general In general, an algebraic data type has one or more data constructors, and each data constructor can have zero or more arguments.

data AlgDataType = Constr1 Type11 Type12

Constr2 Type21
Constr3 Type31 Type32 Type33
Constr4

type and data constructor names must always start with a capital letter

  • Pattern Matching pattern-matching is about taking apart a value by finding out which constructor it was built with. This information can be used as the basis for deciding what to do—indeed, in Haskell, this is the only way to make a decision.

In general, the following grammar defines what can be used as a pattern:

pat ::= _

var
var @ ( pat )
( Constructor pat1 pat2 … patn )

Note that literal values like 2 or ‘c’ can be thought of as constructors with no arguments. It is as if the types Int and Char were defined like

data Int = 0 | 1 | -1 | 2 | -2 | … data Char = ‘a’ | ‘b’ | ‘c’ | …

which means that we can pattern-match against literal values. (Of course, Int and Char are not actually defined this way.)

  • Case expressions case exp of pat1 -> exp1 pat2 -> exp2 …
  • First-class functions
  • Recursive data types

Data types can be recursive, that is, defined in terms of themselves. data IntList = Empty | Cons Int IntList data Tree = Leaf Char

Node Tree Int Tree

deriving Show

Homework 3: Log file parsing

4. Higher-order programming and type inference - BFPG talk based on BYorgey course ../../CIS194/reisenberg/homework/haskell/src/Hw04.hs 5. More polymorphism and type classes - BFPG talk based on BYorgey course ▶Language Pragma {-# LANGUAGE FlexibleInstances #-} That’s a so-called language pragma. GHC includes many features which are not part of the standardized Haskell language. To enable these features, we use language pragmas.

▶Two different forms of polymorfism (1). parametric polymorphism, which we can also call universal polymorphism A function like length :: [a] -> Int works for any type a.

(2).ad-hoc polymorphism - But, sometimes we don’t want to be universal. Sometimes, we want a function to work for several types, but not every type. A great example of this is (+). We want to be able to add Ints and Integers and Doubles, but not Maybe Chars. • This sort of polymorphism – where multiple types are allowed, but not every type – is called ad-hoc polymorphism. Haskell uses type classes to implement ad-hoc polymorphism. A Haskell type class defines a set of operations. We can then choose several types that support those operations via class instances. (Note: These are not the same as object-oriented classes and instances!) Intuitively, type classes correspond to sets of types which have certain operations defined for them.

▶derivable classes This deriving mechanism is baked into Haskell – you can’t make your own class and tell GHC how to derive instances. GHC does provide extensions that allow other classes to be derived; see the GHC manual for details.

  • Eq
  • Ord
  • Enu
  • Ix
  • Bounded
  • Show
  • Read

▶pattern guards parse str

Just rest <- stripPrefix “True” str = Just (True, rest)
Just rest <- stripPrefix “False” str = Just (False, rest)
otherwise = Nothing

Homework 5: Rngs, Parser

Week 6 (2 October): Monoids, I/O

BFPG video 00-14min - seen 14-30min -

Week 7 (16 October): Lazy evaluation

Homework 7:

Week 8 (23 October): Monads

Homework 8:

Week 9 (30 October): Testing

Homework 9: BST, Rings

Week 10 (5 November): Gloss

Homework 10: Pong.jar, Tetris

Week 11 (13 November): Template Haskell

The final projec

Week 12 (20 November): Concurrency & Parallelism

Week 13 (25 November): Types

Week 14 (4 December): Haskell and Java

Week 1 (Wednesday, 21 January): Introduction to Haskell

Homework

Week 2 (Wednesday, 28 January): Polymorphism and Functional Programming

Homework 2:

Week 3 (4 February): Algebraic Data Types

Homework 3:

Week 4 (11 February): Typeclasses

Homework 4

Week 5 (18 February): I/O

Homework 5:

Week 6 (25 February): Lazy Evaluation

Homework 6:

Week 7 (4 March): Monads

Week 8 (18 March): Monads II

Homework 7:

Week 9 (25 March): Testing ( html, lhs )

Week 10 (1 April): Type Wizardry ( html, lhs )

Homework 8:

Week 11 (8 April): GADTs in Action ( html, lhs ) [ Stlc.hs ]

Week 12 (15 April): Unsafe Haskell ( html, lhs )

Write the proposal for your Final Project