1 / 17

Haskell

Dan Johnson. Haskell. History in a Nutshell. Functional language that started development in 1987. Committee designed language Pure and Lazy Compiled or Interpreted Named after Haskell Curry (who has nothing to do with the language itself). The Goals of Haskell.

april
Download Presentation

Haskell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dan Johnson Haskell

  2. History in a Nutshell • Functional language that started development in 1987. • Committee designed language • Pure and Lazy • Compiled or Interpreted • Named after Haskell Curry (who has nothing to do with the language itself)

  3. The Goals of Haskell • It should be suitable for teaching, research, and applications, including building large systems. • It should be completely described via the publication of a formal syntax and semantics. • It should be freely available. • It should be usable as a basis for further language research. • It should be based on ideas that enjoy a wide consensus. • It should reduce unnecessary diversity in functional programming languages.

  4. Prelude • Contains a large number of functions for basic operations and list manipulation. • Loaded automatically when ghci is started

  5. Everything has a type! • Everything is considered to be “of a type”. • A functions type is determined by its return type. • The :: literally means “is of the type”. • Groups of similar types are classified into Typeclasses.

  6. More about types! • Type Inference • Haskell will evaluate the parameters to this function and determine that... • Generally considered bad practice to rely on type inference

  7. Lists and Tuples • Lists function the same way as in Racket. • Tuples are fixed length types that can contain multiple elements of different types. • By combining lists and tuples, you can create complex and powerful data structures

  8. F.. Functions. • Two parts: declaration and definition • Line 34 uses type variables to make the function polymorphic. • Line 35 uses some of the list functions built into prelude

  9. Curried Functions • Two ways to pass multiple parameters to a function: • By using a tuple as the parameter • By defining the function as a curried function • Most multi-parameter functions are curried functions

  10. Higher Order Functions • Any function that returns a function as its result or accepts a function as a parameter • All curried functions are Higher Order functions because their return type is technically a function

  11. Polymorphic Functions • Any function that uses type variables (and only type variables) is considered to be a polymorphic function. • Polymorphic functions are easy to create • Type inference automatically defines polymorphic types when applicable. • Allow for one function to cover a broad range of types • Most functions in the Prelude are polymorphic functions

  12. If .. Then .. vs Guards If .. Then .. Guards • Syntactically similar to most languages • No “else if” statement, must be done with nested ifs • Written more as a mathematician would write a case structure • More readable, less code to write

  13. Recursion • Is at the core of Haskell because it is so prevalent in mathematics • Simply recall the function with different parameters in the function

  14. Object Oriented Design

  15. Lazy Evaluation • Expressions are only evaluated as much as required to produce the final result. • What does this mean? • Why is it important? • Where can we use it?

  16. Purity • Pure languages are said to e languages without side effects • What is a side effect? • Is a pure language even possible? • What are the benefits of purity? • What are the cons of purity?

  17. Hangman

More Related