Looks like no one added any tags here yet for you.
head
select first item of a list
tail
remove first item from a list
[ ] !! n
select the nth element from the list
take n
select the first n elements of a list
drop n
remove the first n elements of a list
length
calculate the length of a list
sum
calculate the sum of a list of numbers
product
calculate product of a list of numbers
++
append two lists
reverse
reverses a list
`div`
back quotes used for division
:reload / :r
reloads file
:load name
loads script name
:edit name
edit script name
:edit
edit current script
:type expr
show type of expr
:?
show all commands
:quit
quit GHCi
_
wildcard pattern, matches any argument value
Num
numeric types
Eq
equality types
Ord
ordered types
Int
fixed position integers
Integer
arbitrary precision integers
list
sequence of values of the same type
tuple
sequence of values of different types
function
a mapping from values of one type to values of another type
curried function
return functions as results, take arguments one at a time
polymorphic functions
if its type contain one or more type variable
overloaded
if its type contains more than one class constraint
higher-order
function that takes a function as an argument
\
lambda
(.)
returns composition of two functions as a single function
all
decides if every list element satisfies a given predicate
any
decides if at least one list element satisfies a predicate
takeWhile
selects elements from a list while a predicate holds all elements
dropWhile
removes elements while a predicate holds all elements
(1+)
successor function
(1/)
reciprocation function
(*2)
doubling function
(/2)
halving function
Zip
maps two lists to a list of pairs of their corresponding elements
string
sequence of characters
()
tuple with no components
getChar :: IO Char
reads characters from keyboard and returns it
putChar :: Char -> IO()
writes character to the screen
>>=
combinators
Steps of verification
1) give a formal specification of the desired property of the program
2) give a proof that the program meets the specification for all inputs
P(n)
invariant of a function
logic programming
prolog
functional programming
haskell
Map
applies a function to every element of a list
filter
selects every element from a list that satisfies a predicate
foldr
simultaneously replacing : in a list by a given function and [ ] by a given value
concat
concatenates a list of lists
type
name for a collection of related values
How can interactive programs be written in Haskell
using types to distinguish pure expressions from impure actions that may involve side effects
Why are type declarations made?
can make other types easier to read
Why are higher-order functions useful?
- Common programming idioms can we written as functions in the language
- Domain specific languages can be defined with appropriate collections of higher order functions
- We can use algebraic properties of higher order functions to reason about programs
Why is flodr useful?
- some recursive functions on lists, such as sum are simpler to define using foldr
- properties of functions defined using foldr can be proved using its algebraic properties
- advanced program optimisations can be simpler if foldr is used in place of explicit recursion
type variables
can be instantiated to different types in different circumstances