Glasgow Haskell Compiler

The Glasgow Haskell Compiler
Original author(s)Kevin Hammond
Developer(s)Simon Marlow, Simon Peyton Jones, The Glasgow Haskell Team[1]
Initial releaseDecember 1992; 31 years ago (1992-12)[2]
Stable release
9.8.1 Edit this on Wikidata / 9 October 2023; 11 months ago (9 October 2023)[3]
Repository
Written inHaskell, C
Operating systemLinux, macOS Catalina[4] and later, Windows 2000 and later, FreeBSD
Platformx86-64[4], AArch64
Available inEnglish
TypeCompiler
LicenseBSD New
Websitewww.haskell.org/ghc

The Glasgow Haskell Compiler (GHC) is a native or machine code compiler for the functional programming language Haskell.[5] It provides a cross-platform software environment for writing and testing Haskell code and supports many extensions, libraries, and optimisations that streamline the process of generating and executing code. GHC is the most commonly used Haskell compiler.[6] It is free and open-source software released under a BSD license.

History

GHC originally begun in 1989 as a prototype, written in Lazy ML (LML) by Kevin Hammond at the University of Glasgow. Later that year, the prototype was completely rewritten in Haskell, except for its parser, by Cordelia Hall, Will Partain, and Simon Peyton Jones. Its first beta release was on 1 April 1991. Later releases added a strictness analyzer and language extensions such as monadic I/O, mutable arrays, unboxed data types, concurrent and parallel programming models (such as software transactional memory and data parallelism) and a profiler.[2]

Peyton Jones, and Marlow, later moved to Microsoft Research in Cambridge, where they continued to be primarily responsible for developing GHC. GHC also contains code from more than three hundred other contributors.[1] From 2009 to about 2014, third-party contributions to GHC were funded by the Industrial Haskell Group.[7]

GHC names

Since early releases the official website[8] has referred to GHC as The Glasgow Haskell Compiler, whereas in the executable version command it is identified as The Glorious Glasgow Haskell Compilation System.[9] This has been reflected in the documentation.[10] Initially, it had the internal name of The Glamorous Glasgow Haskell Compiler.[11]

Architecture

GHC is written in Haskell,[12] but the runtime system for Haskell, essential to run programs, is written in C and C--.

GHC's front end, incorporating the lexer, parser and typechecker, is designed to preserve as much information about the source language as possible until after type inference is complete, toward the goal of providing clear error messages to users.[2] After type checking, the Haskell code is desugared into a typed intermediate language known as "Core" (based on System F, extended with let and case expressions). Core has been extended to support generalized algebraic datatypes in its type system, and is now based on an extension to System F known as System FC.[13]

In the tradition of type-directed compiling, GHC's simplifier, or "middle end", where most of the optimizations implemented in GHC are performed, is structured as a series of source-to-source transformations on Core code. The analyses and transformations performed in this compiler stage include demand analysis (a generalization of strictness analysis), application of user-defined rewrite rules (including a set of rules included in GHC's standard libraries that performs foldr/build fusion), unfolding (called "inlining" in more traditional compilers), let-floating, an analysis that determines which function arguments can be unboxed, constructed product result analysis, specialization of overloaded functions, and a set of simpler local transformations such as constant folding and beta reduction.[14]

The back end of the compiler transforms Core code into an internal representation of C--, via an intermediate language STG (short for "Spineless Tagless G-machine").[15] The C-- code can then take one of three routes: it is either printed as C code for compilation with GCC, converted directly into native machine code (the traditional "code generation" phase), or converted to LLVM IR for compilation with LLVM. In all three cases, the resultant native code is finally linked against the GHC runtime system to produce an executable.

Language

GHC complies with the language standards, both Haskell 98[16] and Haskell 2010.[17] It also supports many optional extensions to the Haskell standard: for example, the software transactional memory (STM) library, which allows for Composable Memory Transactions.

Extensions to Haskell

Many extensions to Haskell have been proposed. These provide features not described in the language specification, or they redefine existing constructs. As such, each extension may not be supported by all Haskell implementations. There is an ongoing effort[18] to describe extensions and select those which will be included in future versions of the language specification.

The extensions[19] supported by the Glasgow Haskell Compiler include:

  • Unboxed types and operations. These represent the primitive datatypes of the underlying hardware, without the indirection of a pointer to the heap or the possibility of deferred evaluation. Numerically intensive code can be significantly faster when coded using these types.
  • The ability to specify strict evaluation for a value, pattern binding, or datatype field.
  • More convenient syntax for working with modules, patterns, list comprehensions, operators, records, and tuples.
  • Syntactic sugar for computing with arrows and recursively-defined monadic values. Both of these concepts extend the monadic do-notation provided in standard Haskell.
  • A significantly more powerful system of types and typeclasses, described below.
  • Template Haskell, a system for compile-time metaprogramming. Expressions can be written to produce Haskell code in the form of an abstract syntax tree. These expressions are typechecked and evaluated at compile time; the generated code is then included as if it were part of the original code. Together with the ability to reflect on definitions, this provides a powerful tool for further extensions to the language.
  • Quasi-quotation, which allows the user to define new concrete syntax for expressions and patterns. Quasi-quotation is useful when a metaprogram written in Haskell manipulates code written in a language other than Haskell.
  • Generic typeclasses, which specify functions solely in terms of the algebraic structure of the types they operate on.
  • Parallel evaluation of expressions using multiple CPU cores. This does not require explicitly spawning threads. The distribution of work happens implicitly, based on annotations provided in the program.
  • Compiler pragmas for directing optimizations such as inline expansion and specializing functions for particular types.
  • Customizable rewrite rules are rules describing how to replace one expression with an equivalent, but more efficiently evaluated expression. These are used within core data structure libraries to provide improved performance throughout application-level code.[20]
  • Record dot syntax. Provides syntactic sugar for accessing the fields of a (potentially nested) record which is similar to the syntax of many other programming languages.[21]

Type system extensions

An expressive static type system is one of the major defining features of Haskell. Accordingly, much of the work in extending the language has been directed towards data types and type classes.

The Glasgow Haskell Compiler supports an extended type system based on the theoretical System FC.[13] Major extensions to the type system include:

  • Arbitrary-rank and impredicative polymorphism. Essentially, a polymorphic function or datatype constructor may require that one of its arguments is also polymorphic.
  • Generalized algebraic data types. Each constructor of a polymorphic datatype can encode information into the resulting type. A function which pattern-matches on this type can use the per-constructor type information to perform more specific operations on data.
  • Existential types. These can be used to "bundle" some data together with operations on that data, in such a way that the operations can be used without exposing the specific type of the underlying data. Such a value is very similar to an object as found in object-oriented programming languages.
  • Data types that do not actually contain any values. These can be useful to represent data in type-level metaprogramming.
  • Type families: user-defined functions from types to types. Whereas parametric polymorphism provides the same structure for every type instantiation, type families provide ad hoc polymorphism with implementations that can differ between instantiations. Use cases include content-aware optimizing containers and type-level metaprogramming.
  • Implicit function parameters that have dynamic scope. These are represented in types in much the same way as type class constraints.
  • Linear types (GHC 9.0)

Extensions relating to type classes include:

  • A type class may be parametrized on more than one type. Thus a type class can describe not only a set of types, but an n-ary relation on types.
  • Functional dependencies, which constrain parts of that relation to be a mathematical function on types. That is, the constraint specifies that some type class parameter is completely determined once some other set of parameters is fixed. This guides the process of type inference in situations where otherwise there would be ambiguity.
  • Significantly relaxed rules regarding the allowable shape of type class instances. When these are enabled in full, the type class system becomes a Turing-complete language for logic programming at compile time.
  • Type families, as described above, may also be associated with a type class.
  • The automatic generation of certain type class instances is extended in several ways. New type classes for generic programming and common recursion patterns are supported. Also, when a new type is declared as isomorphic to an existing type, any type class instance declared for the underlying type may be lifted to the new type "for free".

Portability

Versions of GHC are available for several system or computing platform, including Windows and most varieties of Unix (such as Linux, FreeBSD, OpenBSD, and macOS).[22] GHC has also been ported to several different processor architectures.[22]

See also

References

  1. ^ a b "The GHC Team". Haskell.org. Retrieved 1 September 2016.
  2. ^ a b c Hudak, P.; Hughes, J.; Peyton Jones, S.; Wadler, P. (June 2007). "A History of Haskell: Being Lazy With Class" (PDF). Procedures of the Third ACM SIGPLAN History of Programming Languages Conference (HOPL-III). Retrieved 1 September 2016.
  3. ^ "Download – The Glasgow Haskell Compiler". Haskell.org.
  4. ^ a b "Deprecation of 32-bit Darwin and Windows platforms". GHC Team.
  5. ^ "The Glorious Glasgow Haskell Compilation System User's Guide". Haskell.org. Retrieved 27 July 2014.
  6. ^ "2017 state of Haskell survey results". taylor.fausak.me. 15 November 2017. Retrieved 11 December 2017.
  7. ^ "Industrial Haskell Group". Haskell.org. 2014. Retrieved 1 September 2016.
  8. ^ "GHC The Glasgow Haskell Compiler". Haskell.org. Retrieved 14 January 2022.
  9. ^ "Repository: configure.ac". gitlab.haskell.org. 12 January 2022. Retrieved 14 January 2022.
  10. ^ "The Glorious Glasgow Haskell Compilation System User's Guide, Version 7.6.3". downloads.haskell.org. Retrieved 14 January 2022.
  11. ^ "ghc-0.29-src.tar.gz" (tar gzip). downloads.haskell.org. File: ghc-0.29/ghc/PATCHLEVEL. Retrieved 14 January 2022.
  12. ^ "GHC Commentary: The Compiler". Haskell.org. 23 March 2016. Archived from the original on 23 March 2016. Retrieved 26 May 2016.
  13. ^ a b Sulzmann, M.; Chakravarty, M. M. T.; Peyton Jones, S.; Donnelly, K. (January 2007). "System F with Type Equality Coercions". Procedures of the ACM Workshop on Types in Language Design and Implementation (TLDI).
  14. ^ Peyton Jones, S. (April 1996). "Compiling Haskell by program transformation: a report from the trenches". Procedures of the European Symposium on Programming (ESOP).
  15. ^ Peyton Jones, S. (April 1992). "Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine, Version 2.5". Journal of Functional Programming. 2 (2): 127–202. doi:10.1017/S0956796800000319.
  16. ^ "Haskell 98 Language and Libraries: The Revised Report". Haskell.org. Retrieved 28 January 2007.
  17. ^ "Haskell 2010 Language Report". Haskell.org. Retrieved 30 August 2012.
  18. ^ "Welcome to Haskell' (Haskell Prime)". Haskell.org. Archived from the original on 20 February 2016. Retrieved 26 May 2016.
  19. ^ "GHC Language Features". Haskell.org. Archived from the original on 29 June 2016. Retrieved 25 May 2016.
  20. ^ Coutts, D.; Leshchinskiy, R.; Stewart, D. (April 2007). "Stream Fusion: From Lists to Streams to Nothing at All". Procedures of the ACM SIGPLAN International Conference on Functional Programming (ICFP). Archived from the original on 23 September 2007.
  21. ^ Mitchell, Neil; Fletcher, Shayne (3 May 2020). "Record Dot Syntax". ghc-proposals. GitHub. Retrieved 30 June 2020.
  22. ^ a b Platforms at gitlab.haskell.org

Read other articles:

Artikel ini perlu dikembangkan dari artikel terkait di Wikipedia bahasa Inggris. (Mei 2023) klik [tampil] untuk melihat petunjuk sebelum menerjemahkan. Lihat versi terjemahan mesin dari artikel bahasa Inggris. Terjemahan mesin Google adalah titik awal yang berguna untuk terjemahan, tapi penerjemah harus merevisi kesalahan yang diperlukan dan meyakinkan bahwa hasil terjemahan tersebut akurat, bukan hanya salin-tempel teks hasil terjemahan mesin ke dalam Wikipedia bahasa Indonesia. Jangan men…

Dua ramekin dengan gaya Sebuah ramekin dengan eksterior polos Sebuah ramekin putih Ramekin (/ˈræmɪkɪn/, /ˈræmkɪn/; juga dieja ramequin) adalah tempat hidangan kecil yang biasa digunakan untuk keperluan kuliner. Tempat ini berupa piring kue yang terutama digunakan untuk menyimpah hidangan kecil. Diameternya sekitar 3-4 inci, dengan volume yang umumnya 90 ml, 135 ml, 150 ml, dan 200 ml (3 oz, 4 1/2 oz, 5 oz, 7 oz.)[1] Nama Istilah ini berasal dari bahasa Prancis yaitu ramequin, hida…

Bretman RockRock tahun 2019LahirBretman Rock Sacayanan Laforga31 Juli 1998 (umur 25)Sanchez Mira, Cagayan, FilipinaPekerjaanYouTubermakeup artisAgenAdober Studios (2016)Informasi YouTubeKanal Bretman Rock Tahun aktif2015–sekarangPelanggan8.87 juta[1]Total tayang572.36 juta[1] Penghargaan Kreator 100.000 pelanggan 1.000.000 pelanggan Diperbarui: 15 Mei 2021 Bretman Rock Sacayanan Laforga (lahir 31 Juli 1998) adalah influencer kecantikan dan tokoh media sosial asal…

Peta menunjukkan lokasi Claveria Claveria adalah munisipalitas yang terletak di provinsi Misamis Oriental, Filipina. Pada tahun 2010, munisipalitas ini memiliki populasi sebesar 52.483 jiwa dan 8.904 rumah tangga. Pembagian wilayah Secara administratif Claveria terbagi menjadi 24 barangay, yaitu: Sebaran penduduk di wilayah Claveria Nama Barangay Penduduk (2007) Persentase Ani-e 3,198 7.3 % Aposkahoy 2,402 5.5 % Bulahan 1,311 3.0 % Cabacungan 1,308 3.0 % Pelaez (Don Gregorio …

Sea

Large body of salt water This article focuses on human experience, history, and culture of the collective seas of Earth. For natural science aspects, see more at Ocean. For individual seas, see List of seas. For other uses, see Sea (disambiguation) and The Sea (disambiguation). Atlantic Ocean near the Faroe Islands. A sea is a large body of salty water. There are particular seas and the sea. The sea commonly refers to the ocean, the wider body of seawater. Particular seas are either ma…

Nick JonasJonas saat di Festival Film Cannes 2019LahirNicholas Jerry Jonas16 September 1992 (umur 31)Dallas, Texas, Amerika SerikatPekerjaanPenyanyipenulis laguaktorTahun aktif2000–sekarangSuami/istriPriyanka Chopra ​(m. 2018)​Anak1Karier musikGenrePoppop rockR&BInstrumenGitarbasspianokeyboardperkusidrumsLabelWalt DisneyColumbiaHollywoodIslandSafehouseArtis terkaitJonas BrothersNick Jonas & the AdministrationDemi LovatoSitus webnickjonas.com Nicho…

Peter SelfridgeChief of Protocol of the United StatesIn officeMay 13, 2014 – January 20, 2017PresidentBarack ObamaPreceded byNatalie Jones (Acting)Succeeded bySean Lawler Personal detailsBorn1971 (age 52–53)[1]Alma materUniversity of IowaJohns Hopkins University Peter A. Selfridge (born 1971)[1] is a former U.S. public servant who served as the United States Chief of Protocol from 2014 to 2017. In this role, he served as the link between the White House and …

Rhea ChakrabortyChakraborty pada tahun 2020Lahir1 Juli 1992 (umur 31)Bangalore, Karnataka, IndiaKebangsaanIndianPekerjaanaktrisVJTahun aktif2009—sekarangKota asalBangalore Rhea Chakraborty (lahir 1 Juli 1992) adalah seorang aktris film India.[1][2] Dia memulai sebagai VJ di MTV India.[3] Pada 2013, ia membuat Bollywood debutnya dengan film Mere Dad Ki Maruti disutradarai oleh Ashima Chibber. Rhea Chakraborty dipenjara karna kasus kepemilikan narkoba.[…

Moon of Neptune DespinaDespina as seen by Voyager 2 (smeared horizontally)Discovery[1]Discovered byStephen P. Synnott and Voyager Imaging TeamDiscovery dateJuly 1989DesignationsDesignationNeptune VPronunciation/dəˈspaɪnə, dəˈspiːnə, dɛ-/Named afterΔέσποινα DespœnaAdjectivesDespinianOrbital characteristics[2][3]Epoch 18 August 1989Semi-major axis52 525.95 kmEccentricity0.00038 ± 0.00016Orbital period (sidereal)0.33465551 ± 0.00000001 dInc…

This article may need to be rewritten to comply with Wikipedia's quality standards. You can help. The talk page may contain suggestions. (June 2023) SaintMatrona of PergeAn illustration from the Menologion of Basil IIBornunknown (6th century)Perge, Asia MinorDiedunknownVenerated inEastern Orthodox ChurchFeastNovember 9 Matrona of Perge of the 6th century was a Byzantine female saint known for temporarily cross-dressing as the monk Babylos to avoid her husband after she decided to live follo…

Untuk kegunaan lain, lihat Bukan Cinderella. Bukan CinderellaPoster resmiSutradaraAdi GarinProduserUnchu ViejaySkenarioQueenBCeritaDhety AzmiBerdasarkanBukan Cinderellaoleh Dhety AzmiPemeran Fujianti Utami Rafael Adwel Penata musikGanden BramantoSinematograferFachmi J SaadPenyuntingAugit PrimaPerusahaanproduksiSuper Media PicturesTanggal rilis 28 Juli 2022 (2022-07-28) (Indonesia) Durasi88 menitNegaraIndonesiaBahasaBahasa Indonesia Bukan Cinderella adalah film drama komedi romanti…

Leonard Cohen discographyLeonard Cohen in 1988, around the release of I'm Your Man.Studio albums15Live albums10Compilation albums9Video albums12Music videos32EPs4Singles41Soundtrack albums7 Leonard Cohen was a Canadian singer-songwriter and poet who was active in music from 1967 until his death in 2016. Cohen released 14 studio albums and eight live albums during the course of a recording career lasting almost 50 years, throughout which he remained an active poet. His entire catalogue is availab…

Resolusi 1084Dewan Keamanan PBBSahara Barat dengan wilayah yang dikuasai Maroko (kuning) dan Polisario (merah)Tanggal27 November 1996Sidang no.3.718KodeS/RES/1084 (Dokumen)TopikSahara BaratRingkasan hasil15 mendukungTidak ada menentangTidak ada abstainHasilDiadopsiKomposisi Dewan KeamananAnggota tetap Tiongkok Prancis Rusia Britania Raya Amerika SerikatAnggota tidak tetap Botswana Chili Mesir Guinea-Bissau Jerman Honduras Indo…

Questa voce sull'argomento società calcistiche nordirlandesi è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Limavady United Football ClubCalcio Segni distintivi Uniformi di gara Casa Trasferta Colori sociali Dati societari Città Limavady Nazione  Irlanda del Nord Confederazione UEFA Federazione IFA Campionato IFA Premiership Fondazione 1884 Allenatore Mark Clyde Stadio The Showgrounds(1800 posti) Palmarès Si invita a seguire il modello di voce Il…

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: RTP África – news · newspapers · books · scholar · JSTOR (December 2023) (Learn how and when to remove this template message) Television channel RTP ÁfricaCountryPortugalBroadcast areaLusophone Africa (Angola, Cape Verde, Equatorial Guinea, Guinea-Bissau, Mozamb…

Untuk kegunaan lain, lihat Kuba (disambiguasi). Republik KubaRepública de Cuba (Spanyol) Bendera Lambang Semboyan: ¡Patria o Muerte, Venceremos!(Spanyol: Tanah air atau Mati, Kita akan Berjaya!)Lagu kebangsaan: El Himno de Bayamo(Indonesia: Lagu Bayamocode: id is deprecated )[1]Perlihatkan BumiPerlihatkan peta Bendera Ibu kota(dan kota terbesar)Havana23°8′N 82°23′W / 23.133°N 82.383°W / 23.133; -82.383Bahasa resmiSpanyolPemerintahanKesatuan Mar…

This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: Proscaline – news · newspapers · books · scholar · JSTOR (July 2019) Proscaline Names Preferred IUPAC name 2-(3,5-Dimethoxy-4-propoxyphenyl)ethan-1-amine Identifiers CAS Number 39201-78-0 Y[EPA] 3D model (JSmol) Interactive image ChEMBL ChEM…

Coppa del Mondo di salto con gli sci 2012 Uomini Donne Vincitori Generale Anders Bardal Sarah Hendrickson Torneo dei quattro trampolini Gregor Schlierenzauer - Volo Robert Kranjec - Torneo a squadre  Austria - Classifica per nazioni  Austria  Stati Uniti Dati manifestazione Tappe 19 9 Gare individuali 27 14 Gare a squadre 6 0 Gare cancellate 1 (individuale) 1 2011 2013 La Coppa del Mondo di salto con gli sci 2012, trentatreesima edizione della manifestazione organizzata dalla Fede…

Nicolas-Jean Hugou de BassvilleBiographieNaissance 7 février 1753AbbevilleDécès 14 janvier 1793 (à 39 ans)RomeNationalité françaiseActivités Journaliste, diplomatemodifier - modifier le code - modifier Wikidata Nicolas-Jean Hugou de Bassville, né le 7 février 1753 à Abbeville et mort assassiné le 14 janvier 1793 à Rome, est un journaliste et diplomate français. Biographie Sa carrière Hugou de Bassville collabore à divers journaux politiques et publie plusieurs ouvrages, parmi…

2019–present protests in Lebanon Not to be confused with October Revolution. This article needs to be updated. Please help update this article to reflect recent events or newly available information. (January 2024) 17 October ProtestsPart of the Second Arab SpringProtesters outside of Riad Al Solh Square in Beirut on 19 October 2019Date17 October 2019 (2019-10-17) – AmbiguousLocationSeveral Cities across LebanonCaused by Austerity Political corruption Interventionism Liquidity…

Kembali kehalaman sebelumnya