Haskell Language

An advanced, purely functional programming language.

Declarative, statically typed code.

  • https://www.haskell.org/
  • Statically typed
  • Type Inference
  • Lazy Evaluation
  • Purely Functional
  • Garbage Collector

Glasgow Haskell Compiler (GHC)

  • Windows 64-bit (x86_64) - 236.0 MB

List & Turple

  • List
    • [1, 2, 3]
    • "abc" == ['a', 'b', 'c']
  • Turple
    • (123, "abc")

let = pattern matching

let x = 4 in x*x

等效于 Tcl 里的

  • apply [list {x} {expr $x*$x}] 4
  • {*}[lambda {x} {expr $x*$x}] 4

_ 忽略匹配

let [a, b, c] = "cat" in a
let [a, _, _] = "cat" in a
let a:_        = "cat" in a

匹配整体

let abc@(a, b, c) = (10, 20, 30) in (abc, a, b, c)