background preloader

Haskell

Facebook Twitter

2.5. The GHCi Debugger. GHCi contains a simple imperative-style debugger in which you can stop a running computation in order to examine the values of variables.

2.5. The GHCi Debugger

The debugger is integrated into GHCi, and is turned on by default: no flags are required to enable the debugging facilities. There is one major restriction: breakpoints and single-stepping are only available in interpreted modules; compiled code is invisible to the debugger[]. The debugger provides the following: The ability to set a breakpoint on a function definition or expression in the program. When the function is called, or the expression evaluated, GHCi suspends execution and returns to the prompt, where you can inspect the values of local variables before continuing with the execution.Execution can be single-stepped: the evaluator will suspend execution approximately after every reduction, allowing local variables to be inspected.

Data.ByteString.Char8. Hoogle. Hoogle is a Haskell API search engine, which allows you to search many standard Haskell libraries by either function name, or by approximate type signature.

Hoogle

Example searches: map (a -> b) -> [a] -> [b] Ord a => [a] -> [a] Data.Map.insert Enter your own search at the top of the page. The Hoogle manual contains more details, including further details on search queries, how to install Hoogle as a command line application and how to integrate Hoogle with Firefox/Emacs/Vim etc. I am very interested in any feedback you may have. Please email me, or add an entry to my bug tracker. Math.Statistics. Modes :: Ord a => [a] -> [(Int, a)]Source Modes returns a sorted list of modes in descending order quantile :: (Fractional b, Ord b) => Double -> [b] -> bSource Sample variance Interquartile range Arbitrary quantile q of an unsorted list.

Math.Statistics

Linreg :: Floating b => [(b, b)] -> (b, b, b)Source Least-squares linear regression of y against x for a |collection of (x, y) data, in the form of (b0, b1, r) |where the regression is y = b0 + b1 * x with Pearson |coefficient r. Data.Map. An efficient implementation of maps from keys to values (dictionaries).

Data.Map

Since many function names (but not the type name) clash with Prelude names, this module is usually imported qualified, e.g. import Data.Map (Map) import qualified Data.Map as Map The implementation of Map is based on size balanced binary trees (or trees of bounded balance) as described by: Stephen Adams, "Efficient sets: a balancing act", Journal of Functional Programming 3(4):553-562, October 1993, J. Data.Map. Note: You should use Data.Map.Strict instead of this module if: You will eventually need all the values stored.The stored values don't represent large virtual data structures to be lazily computed.

Data.Map

An efficient implementation of ordered maps from keys to values (dictionaries). These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g. import qualified Data.Map as Map The implementation of Map is based on size balanced binary trees (or trees of bounded balance) as described by: Stephen Adams, "Efficient sets: a balancing act", Journal of Functional Programming 3(4):553-562, October 1993, Nievergelt and E.M. Note that the implementation is left-biased -- the elements of a first argument are always preferred to the second, for example in union or insert. Operation comments contain the operation time complexity in the Big-O notation ( Regular expressions. 1 Overview Chris Kuklewicz has developed a regular expression library for Haskell that has been implemented with a variety of backends.

Regular expressions

Some of these backends are native Haskell implementations, others are not and rely on external C libraries such libpcre. New users may feel overwhelmed with the various options that are available to them. The following table provides an overview of the various features supported by each backend. There are also a number of alternate or complementary regular expression libs, including: Note: speed is something that should be benchmarked by the actual user, since the story changes so much with the task, new GHC, compiler flags, etc. How to write a Haskell program. A developers' guide to creating a new Haskell project or program, and working in the Haskell developer ecosystem.

How to write a Haskell program

Note: for learning the Haskell language itself we recommend these resources. 1 Recommended tools Almost all new Haskell projects use the following tools. Each is intrinsically useful, but using a set of common tools also helps everyone by increasing productivity, and you're more likely to get patches. 1.1 Revision control Use git or darcs unless you have a specific reason not to. The Haskell Heap. The Haskell heap is a rather strange place.

The Haskell Heap

It’s not like the heap of a traditional, strictly evaluated language... ...which contains a lot of junk! (Plain old data.) In the Haskell heap, every item is wrapped up nicely in a box: the Haskell heap is a heap of presents (thunks). When you actually want what’s inside the present, you open it up (evaluate it). Presents tend to have names, and sometimes when you open a present, you get a gift card (data constructor). But just as gift cards can lie around unused (that’s how the gift card companies make money!) Presents on the Haskell heap are rather mischievous.

Understanding what happens when you open a present is key to understanding the time and space behavior of Haskell programs. In this series, Edward makes a foray into the webcomic world in order to illustrate the key operational concepts of evaluation in a lazily evaluated language.