Loading presentation...
Prezi is an interactive zooming presentation

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks


No description

Daniel Hanover

on 28 February 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Haskell

Reduce code volume
Reduce code complexity
Increase program efficiency when dealing with large datasets (lazy evaluation)
Simplest Turing-Complete Programming Language EVER!
variables all single-letters a...z
defining functions: λ<arguments>.<output>
Using functions: λx.xy applies identity function to y
λx.xy → y
Expressions evaluated left-to-right
Variable Types:
Bound: part of function definitions, can be replaced by any letter
Free: function input
in λx.xy, x is bound and y is free (λx.xy = λt.ty)
and how Lambdaλ Calculus will explode your brain
Haskell: Functional Programming
λ Calculus
Declaring Functions
Haskell - Syntax
Haskell in the real world - QuickSort
Only 2 keywords: lambda and "."
See the alligator-and-egg paradigm at: http://worrydream.com/AlligatorEggs/
λx.x is the identity function
The Basics
Data: Numbers and Booleans
Numbers defined recursively:
1 = λxy.x(y)
2 = λxy.x(x(y))
3 = λxy.x(x(x(y)))
True = λxy.x
False = λxy.y
Church Numerals
Data Structures:
Array: λx.xab
"a" holds first element
"b" holds the rest
Working With Data
Increment Function
1. λwyx.y(wyx)(λuv.uuv)
Multiplication Function
Exponential Function
No free variables
2. λyx.y((λuv.uuv)yx)
3. λyx.y(yyx)
4. λyx.yyyx = 3
1. (λxy.xy(λst.t))(λpq.q)(λst.s)
2. ((λpq.q)(λst.s)(λst.t))
3. (λst.t) = F
Syntactic Sugar
Function Header
Return statement
No variables!
No loops!
Using Functions
Dollar Symbol
: Print thinks its being given two arguments, but it can only handle one
Expressions within parenthesis evaluated before being passed to print (Output: "7.2")
All content after $ evaluated first
Converts prefix function to infix
funcName arg1 arg2 == arg1 `funcName` arg2
Grave Accent (`)
Programming Shortcuts that make life easier
Static Typing
Haskell Features
“polymorphically statically typed, lazy, purely functional language.”
Lazy Evaluation
Expressions are not executed until they are needed
What it is
Doesn't execute unnecessary code - increased efficiency
Allows creation of infinite data structures
Full data structure not stored in memory, elements stored when needed
Completes in a matter of picoseconds
...as opposed to dynamic typing
Variable (or function) data types determined at compile-time
Prevents runtime bugs
Catch bugs before releasing to public
Fewer patches needed
Compiler knows exactly how much storage to allocate for each piece of data
Java also features static typing: Int x = 5
It's a fairly common feature...
Haskell methods do not need to specify input types
let's modify our previous sumMeth function:
works with all data types for which + is defined (Ints, Doubles, etc.)
Does same thing, regardless of input type
Similar to Java's method overloading
Does different things, depending on input type
C - 24 lines
Haskell - 6 lines
Haskell - 3 lines
Super elegant coding!
Syntactic Sugar - List Comprehensions
Increased readability
Slightlyless efficient code
Haskell in the real world - Base Conversion
recursively applies lambda function to the elements of ds
'n' is updated to the running sum (starts at 0)
'k' is the next element of the list
See "out of the tar pit"
Haskell: Conclusions
Decreases program efficiency in some cases, but not by a significant amnt
Haskell is capable of creating much more professional, elegant, and comprehensible solutions to many Computer Science problems, albeit at a slight efficiency cost. However, in today's GHz-processor world, micro-optimization techniques are diminishing in importance. In addition, as this modern technology leads to the creation of increasingly complex software, having manageable, comprehensible code is becoming a much higher priority.
Full transcript