Skip to content

Latest commit

 

History

History
86 lines (62 loc) · 3.57 KB

File metadata and controls

86 lines (62 loc) · 3.57 KB

Functional Programming by Example

Haskell

Overview

  • Pure Functional programming language
  • Strong Static Typed Language
  • Type Inference (The Haskell compiler deduce the types for you).
  • Lazy Evaluation ( Delayed evaluation) by default
  • Data Immutability/ Haskell has no variables
    • Values can be bound to a name and can only be assigned once.
    • Values can never change.
  • Haskell has not for-loop, while statements.
  • Algebraic Data types
  • Pattern Matching
  • Tail Recursions
  • Compiles to native code.

Suffixes of file names for Haskell

.hs    Haskell source code; preprocess, compile

.lhs   literate Haskell source; unlit, preprocess, compile

.hi    Interface file; contains information about exported symbols

.hc    intermediate C files

.x_o   way x object files; common ways are: p, u, s

.x_hi  way x interface files

Toolset

ghc - the Glasgow Haskell CompilerTransforms Haskell Source code .hs into native code.
ghciHaskell Interactive Shell/ Interpreter
runghcHaskell Non Interactive Interpreter
haddockDocumentation tool for annotated Haskell source code
cabalGHC Haskell Cabal package manager

Install Haskell Platform

Binaries and Installation files:

Install Haskell Libraries:

cabal update

cabal install <some package>

GHCI Reference

GHCI Interactive Shell

CommandDescription
:helpShow help
:load [haskell-source.hs] or :l src.hsLoad Haskell Source Code
:reload or :rReload Code after it was edited
:type [symbol] or :t [symbol]Show the Type of a Symbol
:browseGives the type signature of all functions
:set +sPrint timing/memory stats after each evaluation
:{ [code here ] :}Multiline Code
:set prompt “>”Change the prompt to “>”
:cd [directory]change the current working directory to [directory]
:! [shell command>]execute the shell command; :! pwd print the current directory
:quitQuit the interpreter

See also: