everyday programs and exceptions Flashcards
base library
provides the core runtime
hackage
third party libraries
what are some of the top level module hierarchies
control
data
foreign
ghc
system
text
control module
control-flow and functions
e.g.exceptions, concurrency
data module
representation
e.g. graphs and trees
foreign module
interactivity with other languages via the ffi (foreign function interface)
which language do we usually use to call haskell functins
c
ghc module
compiler specific
system module
interactivity with the os, command line, variables, processes etc
e.g. io functions
text module
representing texts without using strings
what is a benefit of the text module
enables language conversion
when should we use exceptions
for things that go wrong rarely not as regular error reporting
e.g. cant write as the disk is too full
what is the module for exceptions
control.exceptions
what are the three main types of exceptions and what are they used for
IO exception: for io actions
ErrorCall: generated by calling the error function
SomeException: represents every type of error
how is control.exceptions represented
via data
how can we make our own error handling without using exceptions
have a run function that calls the function doing the data
that function returns 2 values in a tuple with one of them being a number indicating whether there was an error
the run function takes this and calls the appropriate exception handling function if required
why do we make our own error handling without using exceptions
haskell doesnt have a control flow in the same way that java does
what does the chaining function look like and what does it do
> > =
used for multiple io functions and updates the state of the world as it goes
data.char
for individual characters
e.g. upper to lower case and back
unicode and back
data.list
more complex that the list functions in the prelude
can also be used on strings as theyre a list of characters
lines (data.list)
creates an array from a given string with \n being the separator
unlines (data.list)
creates a string from an array with \n between
words (data.list)
creates an array from a given string with white space as separators
unwords (data.list)
creates a string from an array with white spaces between