Haskell programming language.

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

What's new in Microsoft Visual C Preview
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Programming Languages and Paradigms The C Programming Language.
Kathleen Fisher cs242 Reading: “A history of Haskell: Being lazy with class”,A history of Haskell: Being lazy with class Section 6.4 and Section 7 “Monads.
Grab Bag of Interesting Stuff. Topics Higher kinded types Files and handles IOError Arrays.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
0 PROGRAMMING IN HASKELL Chapter 11 - Interactive Programs, Declaring Types and Classes.
PrasadCS7761 Haskell Data Types/ADT/Modules Type/Class Hierarchy Lazy Functional Language.
Haskell programming language. Haskell is… Memory managed (allocation, collection) “Typeful” (static, strong) – Types are checked at compile-time – Types.
Sigma Lisp Σλ Sam Davis Nick Alexander. What is Sigma Lisp? ● New dialect of Lisp ● Designed to be as expressive as possible.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Copyright  Hannu Laine C++-programming Part 1 Hannu Laine.
Chapter 9: Functional Programming in a Typed Language.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Haskell: Types and Classes Dr. Hyunyoung Lee.
Functional Programming Language OCaml Tutorial 科大 - 耶鲁联合研究中心
Overview of the Haskell 98 Programming Language
0 Functors in Haskell Adapted from material by Miran Lipovaca.
© M. Winter COSC 4P41 – Functional Programming Programming with actions Why is I/O an issue? I/O is a kind of side-effect. Example: Suppose there.
0 Odds and Ends in Haskell: Folding, I/O, and Functors Adapted from material by Miran Lipovaca.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Interactive Programs: I/O and Monads Dr. Hyunyoung Lee.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Computer Eng. Software Lab II , Semester 2, Who I am: Andrew Davison CoE, WiG Lab Office Functional Programming.
An introduction to functional programming using Haskell CENG242 –Recitation 1.
FASTFAST All rights reserved © MEP Make programming fun again.
1 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
Advanced Functional Programming 2010
Fundamentals of Programming I Overview of Programming
Java Programming: Guided Learning with Early Objects
Principles of programming languages 12: Functional programming
Programming Languages
dr Robert Kowalczyk WMiI UŁ
Types CSCE 314 Spring 2016.
ML: a quasi-functional language with strong typing
Theory of Computation Lecture 4: Programs and Computable Functions II
Programming Languages and Paradigms
Objectives Identify the built-in data types in C++
Context-free Languages
Functional Programming
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Programming Paradigms
C Basics.
PROGRAMMING IN HASKELL
IDENTIFIERS CSC 111.
PROGRAMMING IN HASKELL
Haskell Strings and Tuples
2.1 Parts of a C++ Program.
Programming Languages
FP Foundations, Scheme In Text: Chapter 14.
PROGRAMMING IN HASKELL
Representation, Syntax, Paradigms, Types
Type & Typeclass Syntax in function
Types and Classes in Haskell
Seoul National University
C Programming Getting started Variables Basic C operators Conditionals
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Records and Type Classes
Grab Bag of Interesting Stuff
Programming Languages
Functional Programming
Functional Programming and Haskell
Text Files and Random Numbers
Programming Languages and Paradigms
Overview Before You Start Structure of a Module Ports and Datatypes
Seoul National University
PROGRAMMING IN HASKELL
Functional Programming and Haskell
Records and Type Classes
Presentation transcript:

Haskell programming language

Haskell is… Memory managed (allocation, collection) “Typeful” (static, strong) Types are checked at compile-time Types cannot be coerced (in general) Pure functional programming Emphasis on functions Referential transparency All variables are constant

Haskell - pros & cons Concurrency The #1 on Language Shootout for threading All non-I/O code is concurrent by default (mutations are handled as I/O code) Readability No parentheses or commas Higher-order functions reduce lines-of-code (no syntax as a reminder of context)

Haskell - namespaces Main main True a Bool Eq -- modules (packages) -- value variables (functions) -- value constructors -- type variables (generics) -- type constructors -- type classes (interfaces)

Haskell - syntax Derived syntax f x = expr (x *) (* y) (*) x `times` y f $ g $ h x (f . g . h) x do a; b; c Core syntax f = \x -> expr \y -> x * y \x -> x * y \x y -> x * y times x y f (g (h x)) a >>= b >>= c -- lambda -- sections -- infix func -- parens -- compose -- I/O bind

Haskell - type syntax life = 42 :: Int life :: Int life = 42

Haskell - types “Hello” :: String length :: [a] -> Int floor :: Float -> Int map :: (a -> b) -> [a] -> [b] 42 :: Int (+) :: Int -> Int -> Int 42 :: Num a => a (+) :: Num a => a -> a -> a

Haskell - type system Int, Word, Float, Double, Char type String = [Char] data Maybe a = Nothing | Just a class Eq a where (==), (/=) :: a -> a -> Bool instance Eq Bool where True == True = True False == False = True _ == _ = False -- built-in types -- type synonyms -- data types -- type classes -- type class instances

Haskell - datatypes -- enumerations -- generics -- unlabeled record data Bool = False | True data Tree a = Leaf a | Branch (Tree a) (Tree a) data Rect = Rect Int Int Int Int data Rect = Rect { x, y :: Int, width :: Int, height :: Int} -- enumerations -- generics -- unlabeled record -- labeled record

Haskell - example programs main = return () main = putStrLn “Hello World” main = interact id main = interact (unlines . reverse . lines) main = do args <- getArgs case args of "-n":a -> putStr (unwords a) a -> putStrLn (unwords a) -- null program -- hello world -- UNIX cat -- GNU tac -- UNIX echo

version control system

Darcs - overview The Theory of Patches A “branch” is a set of patches “Spontaneous branches” Every checkout is a branch Every checkout is a repository

Darcs - interactive Interactive “pull” You chose what patches to download Interactive “push” You chose what patches to commit externally Interactive “record” You chose what files to commit locally

Parsec parser library

Parsec - combinators many :: Parser a -> Parser [a] optional :: Parser a -> Parser (Maybe a) sepBy :: Parser a -> Parser s -> Parser [a] sepBy1 :: Parser a -> Parser s -> Parser [a] endBy :: Parser a -> Parser s -> Parser [a] endBy1 :: Parser a -> Parser s -> Parser [a] char :: Char -> Parser Char between :: Parser open -> Parser close -> Parser a -> Parser a -- like regex* -- like regex+ -- like regex? -- ... , ... , ... -- ... ; ... ; ... ; -- c -- < ... >

Parsec - example parsers number = many digit string = between (char ‘"’) (many anyChar) lisp = number <|> string <|> identifier <|> parens $ many $ lexeme lisp

xmonad X11 window manager

XMonad - overview Tilling window manager (like Ratpoison) Libraries of extensions and status bars Customizable (config file is the app) Full keyboard accessibility

XMonad - example config module Main where import XMonad import System.Exit import qualified XMonad.StackSet as W import qualified Data.Map as M myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf), ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))] myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w)), ((modMask, button2), (\w -> focus w >> windows W.swapMaster)), ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))] defaults = defaultConfig { keys = myKeys, mouseBindings = myMouseBindings, terminal = "xterm"} main = xmonad defaults

extensible text editor Yi extensible text editor

Yi - overview Extensible Fully dynamic application (hs-plugins) All state is serialized and reloaded Customizable yi --as=vim (for vim key bindings) yi --as=emacs (for emacs key bindings)

Yi - structure Taken from <http://www.cse.unsw.edu.au/~dons/papers/SC05.html>

Haskell Thank You