From 1fe0979739ab52dc35511e29728fb8fab5f489e1 Mon Sep 17 00:00:00 2001 From: Levi Pearson Date: Fri, 22 Aug 2014 16:50:57 -0600 Subject: [PATCH] updates to cs194 + language overview --- haskell/courses/upenn_cs194/week_1.page | 83 +++++++++++++++++++++++++ haskell/language.page | 29 +++++++++ 2 files changed, 112 insertions(+) create mode 100644 haskell/courses/upenn_cs194/week_1.page create mode 100644 haskell/language.page diff --git a/haskell/courses/upenn_cs194/week_1.page b/haskell/courses/upenn_cs194/week_1.page new file mode 100644 index 0000000..87310dc --- /dev/null +++ b/haskell/courses/upenn_cs194/week_1.page @@ -0,0 +1,83 @@ +--- +title: Week One Notes +toc: no +format: markdown +... + +# Week One - Haskell Basics + +## What Is Haskell? + + * Created in late 1980s by academics + * Functional + * Pure + * Lazy + * Statically Typed + +## Course Themes + + * Types + * Abstraction + * Wholemeal Programming + +## Literate Haskell + + * Only lines preceded by '>' are code + * All other lines are comments + +## Declarations of Variables + +~~~ {.haskell} +x :: Int +x = 3 +~~~ + + * Declares a variable `x` of type `Int` + * Defines the value of the variable `x` to be `3` + * `=` is *definition*, not *assignment* + * variables are just names for values + +## Basic Types + + * `Int` - Machine-sized integers + * `Integer` - Arbitrary-precision integers + * `Double` - Double-precision floating point + * `Bool` - Booleans + * `Char` - Unicode characters + * `String` - Lists of characters with special syntax + +## GHCi + + * A Haskell Read Eval Print Loop (REPL) + * `:load` - load a haskell file + * `:reload` - reload the file + * `:type` - return the type of an expression + * `:?` - give a list of commands + +## Arithmetic + + * Infix operators, `+`, `-`, `*`, `\`, `^` + * Negation needs parens: `(-3)` + * `div` for integer division + * `mod` for integer remainder + * Backticks turn named functions to infix operators + +## Boolean Logic + + * + +## Defining Basic Functions + +## Pairs + +## Using Functions, Multiple Arguments + +## Lists + +## Constructing Lists + +## Functions on Lists + +## Combining Functions + +## A Word About Error Messages diff --git a/haskell/language.page b/haskell/language.page new file mode 100644 index 0000000..7fb47ae --- /dev/null +++ b/haskell/language.page @@ -0,0 +1,29 @@ +--- +title: Haskell Language +toc: no +format: markdown +... + +Haskell is a programming language; a formal notation for describing +computation. It can be described in terms of its [syntax]() and +[semantics](). It is also often helpful to know about the [origins]() +and [intuitions]() behind its concepts as well. + +It is one thing to know *about* a language, and quite another to know +how to *use* it well. Learning to express ideas a language effectively +involves the [pragmatics]() of the language. + +# Haskell Programs + +A program in Haskell is a collection of [modules](), including at +least the `Main` module. Modules consist of [declarations](), which +define elements of the program. The declarations contain +[expressions](), which denote [values]() and have [types](). All of +the above are built syntactically from the [lexical structure]() of +text in files. + +# Haskell Tools + +Although Haskell is a useful language for communication of ideas about +computation between humans, it also forms a practical language for +executing programs on computers when coupled with [implementations]().