updates to cs194 + language overview

master
Levi Pearson 2014-08-22 16:50:57 -06:00
parent 23c6661b1d
commit 1fe0979739
2 changed files with 112 additions and 0 deletions

View File

@ -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

29
haskell/language.page Normal file
View File

@ -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]().