fbpx
วิกิพีเดีย

แฮสเคิล (ภาษาโปรแกรม)

ภาษาแฮสเคิล (อังกฤษ: Haskell) /ˈhæskəl/ เป็นภาษาโปรแกรมที่มีวัตถุประสงค์เพื่อใช้การใช้งานที่หลากหลาย (general-purpose) ที่มีการไทป์แบบคงที่ (statically typed) ภาษาแฮสเคิลเป็นภาษาโปรแกรมเชิงฟังก์ชั่นแบบบริสุทธ์ (purely functional programming language) ที่มีลักษณะพิเศษคือการคาดคะเนไทป์ (type inference) และการประเมินผลแบบขี้เกียจ (lazy evaluation). ภาษาแฮสเคิลพัฒนาขึ้นเพื่อการเรียนการสอน การวิจัย รวมไปถึงการประยุกต์ใช้ในเชิงธุรกิจและอุตสาหกรรม ภาษาแฮสเคิลเป็นแรงบันดาลใจให้กับภาษาโปรแกรมอื่น ๆ ที่มีความซับซ้อนอีกหลายภาษาให้มีฟีเจอร์แบบไทป์คลาส (type classes) ซึ่งทำให้ป้องกันการเออเรอร์ของไทป์ ทำให้การโอเปอเรเตอร์โอเวอร์โหลดดิ้ง (operator overloading) มีความปลอดภัยในการใช้ไทป์ หรือ มีไทป์เซฟตี้ (type-safe) มากขึ้น คอมไพเลอร์หลักสำหรับภาษาแฮสเคิลคือ คอมไพเลอร์กลาสโกลว์แฮสเคิล (Glasgow Haskell Compiler หรือ GHC) ภาษาแฮสเคิลตั้งชื่อตามนักตรรกศาสตร์ชาวอเมริกัน แฮสเคิล เคอร์รี่ (Haskell Curry)

แฮสเคิล (Haskell)
นามสกุลของไฟล์.hs, .lhs
กระบวนทัศน์Purely functional
เริ่มเมื่อ1990; 31 ปีที่แล้ว (1990)
ออกแบบโดยLennart Augustsson, Dave Barton, Brian Boutel, Warren Burton, Joseph Fasel, Kevin Hammond, Ralf Hinze, Paul Hudak, John Hughes, Thomas Johnsson, Mark Jones, Simon Peyton Jones, John Launchbury, Erik Meijer, John Peterson, Alastair Reid, Colin Runciman, Philip Wadler
รุ่นเสถียรHaskell 2010 (2010 กรกฎาคม; 11 ปีที่แล้ว (2010-07))
รุ่นทดสอบHaskell 2020 announced
ระบบชนิดตัวแปรInferred, static, strong
ตัวแปลภาษาหลักGHC, Hugs, NHC, JHC, Yhc, UHC
ภาษาย่อยHelium, Gofer
ได้รับอิทธิพลจากClean, FP, Gofer, Hope and Hope+, Id, ISWIM, KRC, Lisp, Miranda, ML and Standard ML, Orwell, SASL, Scheme, SISAL
ส่งอิทธิพลต่อAgda, Bluespec, C++11/Concepts, C#/LINQ, CAL,[ต้องการอ้างอิง] Cayenne, Clean, Clojure, CoffeeScript, Curry, Elm, Epigram,[ต้องการอ้างอิง] Escher, F#, Frege, Hack, Idris, Isabelle, Java/Generics, LiveScript, Mercury, Ωmega,[ต้องการอ้างอิง] PureScript, Python, Raku, Rust, Scala, Swift, Timber, Visual Basic 9.0
ระบบปฏิบัติการCross-platform
เว็บไซต์haskell.org

อรรถศาสตร์ (semantics) หรือ คำต่าง ๆ ที่ใช้โค้ดภาษาแฮสเคิลมีต้นกำเนิดทางประวัติศาสตร์จากภาษามิแรนด้า (Miranda) ซึ่งเป็นภาษาที่กลุ่มนักวิทยาศาสตร์คอมพิวเตอร์ที่ร่วมกันสร้างภาษาแฮสเคิลใช้ในการต่อยอด การกำหนดคุณลักษณะอย่างเป็นทางการสำหรับภาษาแฮสเคิลครั้งสุดท้ายมีขึ้นในเดือนกรกฎาคม ค.ศ.2010 (พ.ศ.2553) ส่วนการพัฒนาคอมไพเลอร์ GHC นั้นมีการปรับปรุงและพัฒนาอยู่เรื่อยมาและทำการขยายศักยภาพของภาษาแฮสเคิลขึ้นไปเรื่อย ๆ

โลโก้ภาษาแฮสเคิล

มีการใช้ภาษาแฮสเคิลในการวิจัยเชิงวิชาการ และภาคธุรกิจอุตสาหกรรมต่าง ๆ ในเดือนกันยายน ค.ศ.2020 (พ.ศ.2563) แฮสเคิลเป็นภาษาที่ได้รับความนิยมในการค้นใน Google เป็นอันดับที่ 28 ในส่วนของผู้ใช้ที่ยังแอคทีฟอยู่บนแพลตฟอร์ม GitHub ในส่วนของ source code repository มี source code ภาษาแฮสเคิลเพียง 1% เท่านั้น

ตัวอย่างโค้ด

ดูเพิ่มเติมที่: [§ Examples]

การเขียนโปรแกรม "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 file main :: IO ()  -- the compiler can infer this type definition main = 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 = 1 factorial 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" function factorial n = product [1..n] -- Using fold (implements "product") factorial n = foldl (*) 1 [1..n] -- Point-free style factorial = foldr (*) 1 . enumFromTo 1 

อ้างอิง

  1. Hudak et al. 2007.
  2. Marlow, Simon (24 November 2009). "Announcing Haskell 2010". http://www.haskell.org/pipermail/haskell/2009-November/021750.html. เรียกข้อมูลเมื่อ 12 March 2011. 
  3. Riedel, Herbert (28 April 2016). "ANN: Haskell Prime 2020 committee has formed". https://mail.haskell.org/pipermail/haskell-prime/2016-April/004050.html. เรียกข้อมูลเมื่อ 6 May 2017. 
  4. Peyton Jones 2003, p. xi
  5. Norell, Ulf (2008). "Dependently Typed Programming in Agda" (PDF). Gothenburg: Chalmers University. สืบค้นเมื่อ 9 February 2012.
  6. Hudak et al. 2007, pp. 12–38, 43.
  7. Stroustrup, Bjarne; Sutton, Andrew (2011). (PDF). คลังข้อมูลเก่า เก็บจาก แหล่งเดิม (PDF) เมื่อ 10 February 2012. Cite journal requires |journal= (help)
  8. Hudak et al. 2007, pp. 12-45–46.
  9. Meijer, Erik (2006). "Confessions of a Used Programming Language Salesman: Getting the Masses Hooked on Haskell". Oopsla 2007. CiteSeerX 10.1.1.72.868.
  10. Meijer, Erik (1 October 2009). "C9 Lectures: Dr. Erik Meijer – Functional Programming Fundamentals, Chapter 1 of 13". Channel 9. Microsoft. สืบค้นเมื่อ 9 February 2012.
  11. Drobi, Sadek (4 March 2009). "Erik Meijer on LINQ". InfoQ. QCon SF 2008: C4Media Inc. สืบค้นเมื่อ 9 February 2012.CS1 maint: location (link)
  12. Hickey, Rich. . Listmania!. คลังข้อมูลเก่า เก็บจาก แหล่งเดิม เมื่อ 3 October 2017. สืบค้นเมื่อ 3 October 2017.
  13. Heller, Martin (18 ตุลาคม 2011). "Turn up your nose at Dart and smell the CoffeeScript". InfoWorld. สืบค้นเมื่อ 2020-07-15.
  14. "Declarative programming in Escher" (PDF). สืบค้นเมื่อ 7 October 2015.
  15. Syme, Don; Granicz, Adam; Cisternino, Antonio (2007). Expert F#. Apress. p. 2. F# also draws from Haskell particularly with regard to two advanced language features called sequence expressions and workflows.
  16. Wechsung, Ingo. "The Frege Programming Language" (PDF). สืบค้นเมื่อ 26 February 2014.
  17. "Facebook Introduces 'Hack,' the Programming Language of the Future". WIRED. 20 March 2014.
  18. "Idris, a dependently typed language". สืบค้นเมื่อ 26 October 2014.
  19. "LiveScript Inspiration". สืบค้นเมื่อ 4 February 2014.
  20. Freeman, Phil (2016). "PureScript by Example". Leanpub. สืบค้นเมื่อ 23 April 2017.
  21. Kuchling, A. M. "Functional Programming HOWTO". Python v2.7.2 documentation. Python Software Foundation. สืบค้นเมื่อ 9 February 2012.
  22. . Perl Foundation Perl 6 Wiki. The Perl Foundation. คลังข้อมูลเก่า เก็บจาก แหล่งเดิม เมื่อ 21 January 2012. สืบค้นเมื่อ 9 February 2012.
  23. "The Rust Reference: Appendix: Influences". สืบค้นเมื่อ 3 February 2016.
  24. Fogus, Michael (6 August 2010). "MartinOdersky take(5) toList". Send More Paramedics. สืบค้นเมื่อ 9 February 2012.
  25. Lattner, Chris (3 June 2014). "Chris Lattner's Homepage". Chris Lattner. สืบค้นเมื่อ 3 June 2014. The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.
  26. "Timber/History". สืบค้นเมื่อ 7 October 2015.
  27. Chevalier, Tim (28 January 2008). "anybody can tell me the pronunciation of "haskell"?". http://www.haskell.org/pipermail/haskell-cafe/2008-January/038756.html. เรียกข้อมูลเมื่อ 12 March 2011. 
  28. Type inference originally using Hindley-Milner type inference
  29. Peyton Jones 2003.
  30. Edward Kmett, Edward Kmett – Type Classes vs. the World
  31. "Haskell in education". สืบค้นเมื่อ 15 February 2016.
  32. "Haskell in research". สืบค้นเมื่อ 15 February 2016.
  33. Mossberg, Erik (2020-06-08), erkmos/haskell-companies, สืบค้นเมื่อ 2020-06-22
  34. "Haskell in industry - HaskellWiki". wiki.haskell.org. สืบค้นเมื่อ 2020-06-22.
  35. . pypl.github.io (ภาษาอังกฤษ). 22 January 2021. คลังข้อมูลเก่า เก็บจาก แหล่งเดิม เมื่อ 17 September 2020. สืบค้นเมื่อ 22 January 2021.

แฮสเค, ภาษาโปรแกรม, ภาษาแฮสเค, งกฤษ, haskell, เป, นภาษาโปรแกรมท, ตถ, ประสงค, เพ, อใช, การใช, งานท, หลากหลาย, general, purpose, การไทป, แบบคงท, statically, typed, ภาษาแฮสเค, ลเป, นภาษาโปรแกรมเช, งฟ, งก, นแบบบร, ทธ, purely, functional, programming, language, กษณ. phasaaehsekhil xngkvs Haskell ˈ h ae s k el 27 epnphasaopraekrmthimiwtthuprasngkhephuxichkarichnganthihlakhlay general purpose thimikarithpaebbkhngthi statically typed phasaaehsekhilepnphasaopraekrmechingfngkchnaebbbrisuthth purely functional programming language thimilksnaphiesskhuxkarkhadkhaenithp type inference aelakarpraeminphlaebbkhiekiyc lazy evaluation 28 29 phasaaehsekhilphthnakhunephuxkareriynkarsxn karwicy rwmipthungkarprayuktichinechingthurkicaelaxutsahkrrm phasaaehsekhilepnaerngbndalicihkbphasaopraekrmxun thimikhwamsbsxnxikhlayphasaihmifiecxraebbithpkhlas type classes sungthaihpxngknkarexxerxrkhxngithp thaihkaroxepxeretxroxewxrohldding operator overloading mikhwamplxdphyinkarichithp hrux miithpesfti type safe makkhun khxmiphelxrhlksahrbphasaaehsekhilkhux khxmiphelxrklasoklwaehsekhil Glasgow Haskell Compiler hrux GHC phasaaehsekhiltngchuxtamnktrrksastrchawxemrikn aehsekhil ekhxrri Haskell Curry 1 aehsekhil Haskell namskulkhxngifl hs lhskrabwnthsnPurely functionalerimemux1990 31 pithiaelw 1990 1 xxkaebbodyLennart Augustsson Dave Barton Brian Boutel Warren Burton Joseph Fasel Kevin Hammond Ralf Hinze Paul Hudak John Hughes Thomas Johnsson Mark Jones Simon Peyton Jones John Launchbury Erik Meijer John Peterson Alastair Reid Colin Runciman Philip WadlerrunesthiyrHaskell 2010 2 2010 krkdakhm 11 pithiaelw 2010 07 runthdsxbHaskell 2020 announced 3 rabbchnidtwaeprInferred static strongtwaeplphasahlkGHC Hugs NHC JHC Yhc UHCphasayxyHelium GoferidrbxiththiphlcakClean 4 FP 4 Gofer 4 Hope and Hope 4 Id 4 ISWIM 4 KRC 4 Lisp 4 Miranda 4 ML and Standard ML 4 Orwell SASL 4 Scheme 4 SISAL 4 sngxiththiphltxAgda 5 Bluespec 6 C 11 Concepts 7 C LINQ 8 9 10 11 CAL txngkarxangxing Cayenne 8 Clean 8 Clojure 12 CoffeeScript 13 Curry 8 Elm Epigram txngkarxangxing Escher 14 F 15 Frege 16 Hack 17 Idris 18 Isabelle 8 Java Generics 8 LiveScript 19 Mercury 8 Wmega txngkarxangxing PureScript 20 Python 8 21 Raku 22 Rust 23 Scala 8 24 Swift 25 Timber 26 Visual Basic 9 0 8 9 rabbptibtikarCross platformewbisthaskell orgxrrthsastr semantics hrux khatang thiichokhdphasaaehsekhilmitnkaenidthangprawtisastrcakphasamiaernda Miranda sungepnphasathiklumnkwithyasastrkhxmphiwetxrthirwmknsrangphasaaehsekhilichinkartxyxd 30 karkahndkhunlksnaxyangepnthangkarsahrbphasaaehsekhilkhrngsudthaymikhunineduxnkrkdakhm kh s 2010 ph s 2553 swnkarphthnakhxmiphelxr GHC nnmikarprbprungaelaphthnaxyueruxymaaelathakarkhyayskyphaphkhxngphasaaehsekhilkhuniperuxy olokphasaaehsekhil mikarichphasaaehsekhilinkarwicyechingwichakar 31 32 aelaphakhthurkicxutsahkrrmtang 33 34 ineduxnknyayn kh s 2020 ph s 2563 aehsekhilepnphasathiidrbkhwamniyminkarkhnin Google epnxndbthi 28 35 inswnkhxngphuichthiyngaexkhthifxyubnaephltfxrm GitHub inswnkhxng source code repository mi source code phasaaehsekhilephiyng 1 ethanntwxyangokhd aekikhduephimetimthi Examples karekhiynopraekrm Hello World program in Haskell only the last line is strictly necessary module Main main where not needed in interpreter is the default in a module file main IO the compiler can infer this type definition main putStrLn Hello World karekhiynfngkchnaefkthxeriyl factorial inaehsekhilsamarthekhiynidhlayaebb Type annotation optional same for each implementation factorial Integral a gt a gt a Using recursion with the ifthenelse expression factorial n if n lt 2 then 1 else n factorial n 1 Using recursion with pattern matching factorial 0 1 factorial n n factorial n 1 Using recursion with guards factorial n n lt 2 1 otherwise n factorial n 1 Using a list and the product function factorial n product 1 n Using fold implements product factorial n foldl 1 1 n Point free style factorial foldr 1 enumFromTo 1xangxing aekikh 1 0 1 1 Hudak et al 2007 Marlow Simon 24 November 2009 Announcing Haskell 2010 http www haskell org pipermail haskell 2009 November 021750 html eriykkhxmulemux 12 March 2011 Riedel Herbert 28 April 2016 ANN Haskell Prime 2020 committee has formed https mail haskell org pipermail haskell prime 2016 April 004050 html eriykkhxmulemux 6 May 2017 4 00 4 01 4 02 4 03 4 04 4 05 4 06 4 07 4 08 4 09 4 10 4 11 4 12 Peyton Jones 2003 p xi Norell Ulf 2008 Dependently Typed Programming in Agda PDF Gothenburg Chalmers University subkhnemux 9 February 2012 Hudak et al 2007 pp 12 38 43 Stroustrup Bjarne Sutton Andrew 2011 Design of Concept Libraries for C PDF khlngkhxmuleka ekbcak aehlngedim PDF emux 10 February 2012 Cite journal requires journal help 8 0 8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 Hudak et al 2007 pp 12 45 46 9 0 9 1 Meijer Erik 2006 Confessions of a Used Programming Language Salesman Getting the Masses Hooked on Haskell Oopsla 2007 CiteSeerX 10 1 1 72 868 Meijer Erik 1 October 2009 C9 Lectures Dr Erik Meijer Functional Programming Fundamentals Chapter 1 of 13 Channel 9 Microsoft subkhnemux 9 February 2012 Drobi Sadek 4 March 2009 Erik Meijer on LINQ InfoQ QCon SF 2008 C4Media Inc subkhnemux 9 February 2012 CS1 maint location link Hickey Rich Clojure Bookshelf Listmania khlngkhxmuleka ekbcak aehlngedim emux 3 October 2017 subkhnemux 3 October 2017 Heller Martin 18 tulakhm 2011 Turn up your nose at Dart and smell the CoffeeScript InfoWorld subkhnemux 2020 07 15 Declarative programming in Escher PDF subkhnemux 7 October 2015 Syme Don Granicz Adam Cisternino Antonio 2007 Expert F Apress p 2 F also draws from Haskell particularly with regard to two advanced language features called sequence expressions and workflows Wechsung Ingo The Frege Programming Language PDF subkhnemux 26 February 2014 Facebook Introduces Hack the Programming Language of the Future WIRED 20 March 2014 Idris a dependently typed language subkhnemux 26 October 2014 LiveScript Inspiration subkhnemux 4 February 2014 Freeman Phil 2016 PureScript by Example Leanpub subkhnemux 23 April 2017 Kuchling A M Functional Programming HOWTO Python v2 7 2 documentation Python Software Foundation subkhnemux 9 February 2012 Glossary of Terms and Jargon Perl Foundation Perl 6 Wiki The Perl Foundation khlngkhxmuleka ekbcak aehlngedim emux 21 January 2012 subkhnemux 9 February 2012 The Rust Reference Appendix Influences subkhnemux 3 February 2016 Fogus Michael 6 August 2010 MartinOdersky take 5 toList Send More Paramedics subkhnemux 9 February 2012 Lattner Chris 3 June 2014 Chris Lattner s Homepage Chris Lattner subkhnemux 3 June 2014 The Swift language is the product of tireless effort from a team of language experts documentation gurus compiler optimization ninjas and an incredibly important internal dogfooding group who provided feedback to help refine and battle test ideas Of course it also greatly benefited from the experiences hard won by many other languages in the field drawing ideas from Objective C Rust Haskell Ruby Python C CLU and far too many others to list Timber History subkhnemux 7 October 2015 Chevalier Tim 28 January 2008 anybody can tell me the pronunciation of haskell http www haskell org pipermail haskell cafe 2008 January 038756 html eriykkhxmulemux 12 March 2011 Type inference originally using Hindley Milner type inference Peyton Jones 2003 Edward Kmett Edward Kmett Type Classes vs the World Haskell in education subkhnemux 15 February 2016 Haskell in research subkhnemux 15 February 2016 Mossberg Erik 2020 06 08 erkmos haskell companies subkhnemux 2020 06 22 Haskell in industry HaskellWiki wiki haskell org subkhnemux 2020 06 22 PYPL PopularitY of Programming Language index pypl github io phasaxngkvs 22 January 2021 khlngkhxmuleka ekbcak aehlngedim emux 17 September 2020 subkhnemux 22 January 2021 ekhathungcak https th wikipedia org w index php title aehsekhil phasaopraekrm amp oldid 9248374, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม