- Why do I like Haskell?
- Why do I dislike Haskell?
- What's CIS 194?
- What's the Plan?
- Walkthrough of course materials
- Tracking your progress
- Participation
- Development environment setup
main = scotty 3000 $ do
get "/:word" $ do
word <- param "word"
html ("<h1>Hello, " ++ word ++ "</h1>")
sum :: (Int, Int) -> Int
sum (x,y) = x + y
sum2 :: (Int, Int) -> IO Int
sum2 (x,y) = do
contents <- readFile "/secret"
putStr contents
return (x + y)
- "Lightweight threads" a la Go (Haskell runtime scheduler)
- Good low-level stuff (
forkIO
,MVar
, etc.) - Cool high-level stuff
- channels
- software transactional memory
- thread-safe mutable variables
fibonacci :: [Int]
fibonacci = 0 : (next 1 1)
where next n m = n : (next m (n + m))
*Main> take 10 $ fibonacci
[0,1,1,2,3,5,8,13,21,34]
A grouping of methods that operate over some type:
class ToJSON a where
toJSON :: a -> Value
A type can instantiate these classes by providing an implementation of each method:
data Person { firstName :: Text
, lastName :: Text }
instance ToJSON Person where
toJSON (Person f l) = object [ "firstName" .= f
, "lastName" .= l ]
Then, we program against the type class instead of an implementation.
createJSONResponse :: ToJSON o => o -> WebServiceResponse ByteString
Instantiate type classes using types you didn't create.
- Separating deterministic and nondeterministic code
- Interesting new abstractions
- How do we write programs where the state is mostly encapsulated in the call stack?
Influenced a lot of stuff:
- Rx (Erik Meijer)
- Java (generics - Philip Wadler et al.)
- Swift (protocols)
- JavaScript (promises chaining)
- Scala (scalaz, cats)
- C# (LINQ - Erik Meijer)
- Lots of interesting new things to learn
- Learning curve very steep
- Poor web-dev library support (relative to say, JavaScript)
- Poor IDE support (relative to say, Java)
- Lots of language pragmas
- Records/fields are stupid (fixed in GHC 8)
- Original course taught by Brett Yorgey @ U-Penn in Spring 2013
- According to me and most people on /r/haskell, it's the best option out there
- Coursework is challenging, illustrative
- Replaced the original IO and Monoids chapters with a single chapter from the Fall '14 version
- Added a chapter on Quickcheck
- Get together at lunch to talk about the week's lecture and ask questions about homework
- Presentations?
- Go here
- Lectures
- Assignments
- Check out: http://coursework-progress.herokuapp.com
- Builds branches w/Travis CI
- Clone the Git repo
- Create a branch from
master
using your GitHub username - Periodically rebase onto
master
(let's share tests!) - Progress app will build your codes and run tests
- I'll buy sandwiches each week for individuals who say they've done the homework by the time I wake up on Thursdays
- Finish Chapter 1 homework
- Read Chapter 2 lecture