เมนูนำทาง
ภาษาแฮสเคิล ตัวอย่างโค้ดการเขียนโปรแกรม "Hello, World!" program ใน Haskell (only the last line is strictly necessary):
module Main (main) where -- not needed in interpreter, is the default in a module filemain :: IO () -- the compiler can infer this type definitionmain = putStrLn "Hello, World!"
การเขียนฟังก์ชั่นแฟกทอเรียล (factorial) ในแฮสเคิลสามารถเขียนได้หลายแบบ:
-- Type annotation (optional, same for each implementation)factorial :: (Integral a) => a -> a-- Using recursion (with the "ifthenelse" expression)factorial n = if n < 2 then 1 else n * factorial (n - 1)-- Using recursion (with pattern matching)factorial 0 = 1factorial n = n * factorial (n - 1)-- Using recursion (with guards)factorial n | n < 2 = 1 | otherwise = n * factorial (n - 1)-- Using a list and the "product" functionfactorial n = product [1..n]-- Using fold (implements "product")factorial n = foldl (*) 1 [1..n]-- Point-free stylefactorial = foldr (*) 1 . enumFromTo 1
เมนูนำทาง
ภาษาแฮสเคิล ตัวอย่างโค้ดใกล้เคียง
ภาษาแต้จิ๋ว ภาษาแมนจู ภาษาแอลเบเนีย ภาษาแฆแลจ ภาษาแฮสเคิล ภาษาแอกแคด ภาษาแอเมอไรต์ ภาษาแอราเมอิกพระเยซู ภาษาแอราเมอิก ภาษาแอราเมอิกใหม่ยิวบาร์ซานแหล่งที่มา
WikiPedia: ภาษาแฮสเคิล http://www.haskell.org/pipermail/haskell-cafe/2008... https://www.youtube.com/watch?v=hIZxTQP1ifo https://wiki.haskell.org/Haskell_in_education https://wiki.haskell.org/Haskell_in_research https://github.com/erkmos/haskell-companies http://wiki.haskell.org/Haskell_in_industry https://web.archive.org/web/20190904174336/http://... http://pypl.github.io/PYPL.html https://www.haskell.org/ https://mail.haskell.org/pipermail/haskell-prime/2...