CSCE 330 Programming Language Structures Literate Programming in Haskell - PowerPoint PPT Presentation

About This Presentation
Title:

CSCE 330 Programming Language Structures Literate Programming in Haskell

Description:

Department of Computer Science and Engineering. Literate Programming ... fact :: Integer - Integer fact 0 = 1 fact n = n * fact (n-1) ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 4
Provided by: MarcoVa
Learn more at: https://www.cse.sc.edu
Category:

less

Transcript and Presenter's Notes

Title: CSCE 330 Programming Language Structures Literate Programming in Haskell


1
CSCE 330Programming Language StructuresLiterate
Programming in Haskell
  • Fall 2009
  • Marco Valtorta
  • mgv_at_cse.sc.edu

2
Literate Programming
  • http//www.haskell.org/haskellwiki/Literate_progra
    mming
  • http//www.haskell.org/onlinereport/literate.html
  • "The main idea is to regard a program as a
    communication to human beings rather than as a
    set of instructions to a computer." Donald
    Knuth
  • Haskell literate programs use the .lhs extension
  • Two styles Bird and LaTeX
  • Hutton uses Bird style

3
Example of Bird Style literate program
  • The literate style encourages comments by making
    them the default. A line in which "gt" is the
    first character is treated as part of the
    program all other lines are comment.
  • In Bird-style you have to leave a blank before
    the code.
  • gt fact Integer -gt Integer
  • gt fact 0 1
  • gt fact n n fact (n-1)
  • And you have to leave a blank line after the code
    as well.
Write a Comment
User Comments (0)
About PowerShow.com