https://wiki.haskell.org/api.php?action=feedcontributions&user=Ppelleti&feedformat=atomHaskellWiki - User contributions [en]2024-03-29T07:40:44ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Mutually_recursive_modules&diff=65248Mutually recursive modules2022-08-07T10:51:01Z<p>Ppelleti: /* GHC */ Fix link to users guide</p>
<hr />
<div>'''Mutually recursive modules''' are modules that import each other.<br />
This way it is not possible to find a sequence to compile them one after another.<br />
This is a typical problem of languages with a strong module system, in contrast to languages like C,<br />
where all parts of a program are merged textually by the preprocessor before compiling them.<br />
<br />
Simple example:<br />
<haskell><br />
module A where<br />
<br />
import B<br />
<br />
<br />
module B where<br />
<br />
import A<br />
</haskell><br />
<br />
If possible, mutually recursive modules should be avoided, since they complicate module dependencies.<br />
Once you have mutually recursive modules in a package,<br />
you will no longer be able to put modules of an import cycle into different packages,<br />
because mutually recursive packages are not supported.<br />
<br />
<br />
== Compiler support ==<br />
<br />
The Haskell 98 report says, that Haskell 98 allows mutually recursive modules,<br />
but not all compilers support them completely or even in a simple way.<br />
<br />
=== GHC ===<br />
<br />
GHC supports mutually recursive modules in a limited way and requires additional information.<br />
You must break the data dependency cycles manually by creating [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/separate_compilation.html#how-to-compile-mutually-recursive-modules .hs-boot files].<br />
Up to version 6.10 it is not possible to create mutually recursive class definitions across modules, e.g.<br />
<haskell><br />
module A where<br />
<br />
import B<br />
<br />
class B t => A t where<br />
...<br />
<br />
<br />
module B where<br />
<br />
import A<br />
<br />
class B t where<br />
f :: A t => t -> t<br />
</haskell><br />
<br />
Not all mutual recursion can be solved by adding *.hs-boot files. For instance:<br />
<br />
In the [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers protocol-buffers] package message definitions are used to generate Haskell source files. The messages *.hs files could be mutually recursive, and in easy cases the mutual recursion can be solved by adding *.hs-boot files and {- SOURCE -} pragmas. In difficult cases it is '''impossible''' to solve the recursion through adding *.hs-boot files, and in these cases the protocol-buffers package generates additional modules to break the difficult recursion cycles. Happily, the API of the message *.hs files does not change, and all the complexity is kept under the hood.<br />
<br />
=== Hugs ===<br />
<br />
Hugs until September 2006 does [http://cvs.haskell.org/Hugs/pages/users_guide/faq.html#AEN1926 not support] mutual recursive modules.<br />
<br />
=== NHC98 ===<br />
<br />
[http://www.haskell.org/pipermail/haskell-cafe/2004-September/006872.html Support] by <code>.hi-boot</code> files.<br />
<br />
=== YHC ===<br />
<br />
?<br />
<br />
=== HBC ===<br />
<br />
?<br />
<br />
=== HHC/Freja ===<br />
<br />
[http://www.haskell.org/pipermail/haskell-cafe/2004-September/006872.html Support] for mutual recursion within modules that are in one file.<br />
<br />
=== PacSoft/Programmatica ===<br />
<br />
[http://www.haskell.org/pipermail/haskell-cafe/2004-September/006872.html Full support]<br />
<br />
<br />
== Resolve mutual recursion ==<br />
<br />
There are some ways to avoid mutually recursive imports, which we will describe below.<br />
<br />
=== Use type parameters ===<br />
<br />
If you have the definitions<br />
<haskell><br />
module A where<br />
<br />
import B<br />
<br />
data A = A B<br />
<br />
<br />
module B where<br />
<br />
import A<br />
<br />
data B = B A<br />
</haskell><br />
then you can break the cycle by adding a type parameter to one of these data declarations.<br />
By thinking about that possibility you might find that you want to generalize one of the data structures anyway.<br />
This yields:<br />
<haskell><br />
module A where<br />
<br />
data A b = A b<br />
<br />
<br />
module B where<br />
<br />
import A<br />
<br />
data B = B (A B)<br />
</haskell><br />
This way you only generalize the data structure.<br />
All functions that use <hask>A</hask> may use it with the fixed type argument <hask>B</hask>.<br />
<br />
<br />
=== Global type definitions ===<br />
<br />
Some packages use to define all data types and classes in one module of the package.<br />
These types are then imported by all other modules of the package.<br />
This may however conflict with the use of [[qualified names]],<br />
since in this style clashes of unqualified type identifiers in the type definition module are more likely.<br />
<br />
== See also ==<br />
<br />
* Haskell Cafe on [http://www.haskell.org/pipermail/haskell-cafe/2004-September/006870.html mutually recursive modules]<br />
* Haskell Cafe on [http://www.haskell.org/pipermail/haskell-cafe/2010-September/083243.html circular imports]<br />
<br />
<br />
[[Category:Glossary]]<br />
[[Category:Idioms]]<br />
[[Category:Style]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Implementations&diff=65245Implementations2022-08-06T07:20:19Z<p>Ppelleti: I had not meant to shortchange Stack when updating the download options</p>
<hr />
<div>Below you will find a list of all Haskell implementations. The [https://www.haskell.org/downloads/ recommended] way to install Haskell on your computer is through [https://www.haskell.org/ghcup/ GHCup] and/or [[Stack|The Haskell Tool Stack]].<br />
<br />
<br />
== Haskell 2010 == <br />
<br />
=== Glasgow Haskell Compiler (GHC) ===<br />
[[GHC]] is an optimising compiler for Haskell, providing many language extensions. GHC is the de facto standard compiler if you want fast code. GHC is written in Haskell (plus extensions), and its size and complexity mean that it is less portable than Hugs, it runs more slowly, and it needs more memory. However, the programs it produces run ''much'' faster.<br />
<br />
There is also an interactive environment, GHCi, which is like Hugs but supports interactive loading of compiled code. GHC provides profiling for time and space, and supports concurrent and parallel programming. It is available for most common platforms, including Windows, Mac OS X, and several Unix variants (Linux, *BSD, Solaris).<br />
<br />
The currently [https://www.haskell.org/downloads/ recommended] way to install GHC and some related tools is with [https://www.haskell.org/ghcup/ GHCup]. There is also an [https://docs.haskellstack.org/en/stable/install_and_upgrade/ installation guide] for [[Stack]].<br />
<br />
Other methods of installation are listed at [[Distributions]].<br />
<br />
The previously recommended [[Haskell Platform]] is now deprecated.<br />
<br />
=== Utrecht Haskell Compiler (UHC) ===<br />
[[UHC]] is a Haskell implementation from Utrecht University. UHC supports almost all Haskell 98 and Haskell 2010 features plus many experimental extensions. The compiler runs on Mac OS X, Windows (Cygwin), and various Unix flavors.<br />
<br />
Features include: Multiple backends, including a bytecode interpreter backend and a whole-program analysis backend based on GRIN. Experimental language extensions, some of which have not been implemented before.<br />
<br />
UHC is implemented using [[Attribute grammar|attribute grammars]], and due to an aspect-oriented internal organisation is ideally suited for experimenting with language extensions.<br />
<br />
On April 18, 2009 UHC was [http://www.cs.uu.nl/wiki/UHC/Announce announced] at the 5th Haskell Hackathon in Utrecht.<br />
<br />
<br />
=== LLVM Haskell Compiler (LHC) ===<br />
[https://github.com/Lemmih/lhc LHC] is a newly reborn project[http://lhc-compiler.blogspot.se/2014/11/the-new-lhc.html] to build a working Haskell 2010 compiler out of reusable blocks. <br />
<br />
<br />
== Haskell 98 ==<br />
<br />
=== Jhc Haskell Compiler ===<br />
[http://repetae.net/computer/jhc/ Jhc] is an experimental compiler with a goal of testing new optimization methods and exploring the design space of Haskell implementations.<br />
<br />
=== Helium ===<br />
[https://github.com/Helium4Haskell/helium Helium] is a functional programming language and a compiler designed especially for teaching Haskell. Quality of the error messages has been the main concern both in the choice of the language features and in the implementation of the compiler. The language is a subset of the Haskell language. The most notable difference with Haskell is the absence of overloading. The compiler keeps track of a lot of information to produce informative messages.<br />
<br />
== Haskell Dialects ==<br />
<br />
=== Discus ===<br />
[http://www.discus-lang.org/ Discus] (formerly known as [http://disciple.ouroborus.net Disciple]) is a dialect of Haskell that uses strict evaluation as the default and supports destructive update of arbitrary data structures. Discus includes region, effect and closure typing, and this extra information provides a handle on the operational behaviour of code that isn't available in other languages. Programs can be written in either a pure/functional or effectful/imperative style, and one of our goals is to provide both styles coherently in the same language. Our compiler is still in the "research prototype" stage, but will compile programs if you are nice to it.<br />
<br />
<br />
=== Frege ===<br />
<br />
[https://github.com/Frege/frege Frege] is a pure functional programming language for the JVM in the spirit of Haskell. It enjoys a strong static type system with powerful type inference and non-strict - also known as lazy - evaluation.<br />
<br />
Frege programs are compiled to Java and run on the JVM.<br />
<br />
The similarity to Haskell is actually strong enough that many users call it "''a'' Haskell for the JVM".<br />
<br />
<br />
== Unmaintained ==<br />
<br />
=== Hugs ===<br />
[[Hugs]] is a small, portable Haskell interpreter written in C runs on almost any machine. Hugs is best used as a Haskell program development system: it boasts extremely fast source code interpretation, supports incremental interpretation, and has the convenience of an interactive interpreter (within which one can move from module to module to test different portions of a program). However, being an interpreter, it does not nearly match the run-time performance of, for example, GHC, nhc98, or HBC. Hugs 98 is conformant with Haskell 98. Available for all Unix platforms including Linux, DOS, Windows 3.x, and Win 32 (Windows 95, Win32s, NT) and Macintoshes. It has many libraries including Win32 libraries, a foreign interface mechanism to facilitate interoperability with C, and the Windows version has a graphical user interface called [[WinHugs]]. Explanations of some common Hugs error messages and their causes can be found on [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/errors.html Simon Thompson's page].<br />
<br />
=== nhc98 ===<br />
[http://www.haskell.org/nhc98/ nhc98] is a small, easy to install, standards-compliant Haskell 98 compiler. It works only on 32-bit machines. It provides some advanced kinds of heap profiles not found in any other Haskell compiler. It produces medium-fast code, and compilation is itself quite fast. The compiler stresses the saving of space, that is, it produces small programs requiring comparatively little space at runtime (and it is itself much smaller than the other compilers). It is available for all Unix-like platforms (including Mac OS X, Cygwin/Windows, Linux, Solaris, *BSD, AIX, HP-UX, Ultrix, IRIX, etc.). It is written in Haskell 98, but can be quickly and easily bootstrapped from C sources.<br />
<br />
=== York Haskell Compiler (YHC) ===<br />
[[Yhc]] is a fork of [http://www.haskell.org/nhc98/ nhc98], with the goals of being simpler, more portable, more efficient and integrating [[Hat]] support.<br />
<br />
=== [http://web.archive.org/web/20090815181116/http://www.cs.chalmers.se/~augustss/hbc/hbc.html '''HBI''' and '''HBC'''], Chalmers' Haskell Interpreter and Compiler ===<br />
The Chalmers Haskell-B compiler 0.9999.5c implements Haskell 98, as well as some extensions. It is written by Lennart Augustsson, and based on the classic LML compiler by Augustsson and Johnsson. The interpreter can also load code compiled with HBC. There has been no official release for the last few years and the support level is pretty low, but the compiler exists and can be used. Unfortunately the web-pages and the documentation has not been updated the last few years! You can download an unofficial [http://haskell.org/hbc/hbc-2004-06-29.src.tar.gz snapshot of the sources] and the corresponding [http://haskell.org/hbc/hbc-2004-06-29.bin-i386-linux.tar.gz x86 Linux binaries] (based on [http://www.cs.chalmers.se/pub/users/hallgren/Alfa/Haskell/ snapshots] from Thomas Hallgren and Magnus Carlsson). Other sources: [https://archive.org/details/haskell-b-compiler https://archive.org/details/haskell-b-compiler].<br />
<br />
=== Yale Haskell ===<br />
[http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/syntax/haskell/0.html Yale Haskell 2.05], an early implementation of Haskell in Lisp. See an early [http://groups.google.com/group/comp.lang.functional/msg/5b929ac0223a6212?dmode=source&hl=en release announcement]. More information is available on the [[Haskell Lisp]] page.<br />
<br />
=== The Brisk compiler ===<br />
A product of the [http://www.cs.bris.ac.uk/Research/LanguagesArchitecture/brisk.html BRISK project] at the University of Bristol investigating the further use of functional programming in systems-level software development. Version [http://www.cs.bris.ac.uk/~ian/Functional/brisk.tgz 0.08] partially implements an early version of Haskell.<br />
<br />
== Comparison of Implementations ==<br />
* Comparison of [https://web.archive.org/web/20160616121712/http://mirror.seize.it/report.html speed and memory usage (Web Archive)] of several Haskell implementations (February 2011). This page also shows how many samples compile/run correctly.<br />
<br />
* A [http://stackoverflow.com/questions/4084790/compilers-for-haskell stackoverflow discussion] of several implementations.<br />
<br />
<br />
[[Category:Implementations| ]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Implementations&diff=65244Implementations2022-08-06T01:54:43Z<p>Ppelleti: recommend GHCup over Haskell Platform, and clean up some previous changes</p>
<hr />
<div>Below you will find a list of all Haskell implementations. The [https://www.haskell.org/downloads/ recommended] way to install Haskell on your computer is through [https://www.haskell.org/ghcup/ GHCup].<br />
<br />
<br />
== Haskell 2010 == <br />
<br />
=== Glasgow Haskell Compiler (GHC) ===<br />
[[GHC]] is an optimising compiler for Haskell, providing many language extensions. GHC is the de facto standard compiler if you want fast code. GHC is written in Haskell (plus extensions), and its size and complexity mean that it is less portable than Hugs, it runs more slowly, and it needs more memory. However, the programs it produces run ''much'' faster.<br />
<br />
There is also an interactive environment, GHCi, which is like Hugs but supports interactive loading of compiled code. GHC provides profiling for time and space, and supports concurrent and parallel programming. It is available for most common platforms, including Windows, Mac OS X, and several Unix variants (Linux, *BSD, Solaris).<br />
<br />
The currently [https://www.haskell.org/downloads/ recommended] way to install GHC and related tools is with [https://www.haskell.org/ghcup/ GHCup].<br />
<br />
Other methods of installation are listed at [[Distributions]].<br />
<br />
The previously recommended [[Haskell Platform]] is now deprecated.<br />
<br />
=== Utrecht Haskell Compiler (UHC) ===<br />
[[UHC]] is a Haskell implementation from Utrecht University. UHC supports almost all Haskell 98 and Haskell 2010 features plus many experimental extensions. The compiler runs on Mac OS X, Windows (Cygwin), and various Unix flavors.<br />
<br />
Features include: Multiple backends, including a bytecode interpreter backend and a whole-program analysis backend based on GRIN. Experimental language extensions, some of which have not been implemented before.<br />
<br />
UHC is implemented using [[Attribute grammar|attribute grammars]], and due to an aspect-oriented internal organisation is ideally suited for experimenting with language extensions.<br />
<br />
On April 18, 2009 UHC was [http://www.cs.uu.nl/wiki/UHC/Announce announced] at the 5th Haskell Hackathon in Utrecht.<br />
<br />
<br />
=== LLVM Haskell Compiler (LHC) ===<br />
[https://github.com/Lemmih/lhc LHC] is a newly reborn project[http://lhc-compiler.blogspot.se/2014/11/the-new-lhc.html] to build a working Haskell 2010 compiler out of reusable blocks. <br />
<br />
<br />
== Haskell 98 ==<br />
<br />
=== Jhc Haskell Compiler ===<br />
[http://repetae.net/computer/jhc/ Jhc] is an experimental compiler with a goal of testing new optimization methods and exploring the design space of Haskell implementations.<br />
<br />
=== Helium ===<br />
[https://github.com/Helium4Haskell/helium Helium] is a functional programming language and a compiler designed especially for teaching Haskell. Quality of the error messages has been the main concern both in the choice of the language features and in the implementation of the compiler. The language is a subset of the Haskell language. The most notable difference with Haskell is the absence of overloading. The compiler keeps track of a lot of information to produce informative messages.<br />
<br />
== Haskell Dialects ==<br />
<br />
=== Discus ===<br />
[http://www.discus-lang.org/ Discus] (formerly known as [http://disciple.ouroborus.net Disciple]) is a dialect of Haskell that uses strict evaluation as the default and supports destructive update of arbitrary data structures. Discus includes region, effect and closure typing, and this extra information provides a handle on the operational behaviour of code that isn't available in other languages. Programs can be written in either a pure/functional or effectful/imperative style, and one of our goals is to provide both styles coherently in the same language. Our compiler is still in the "research prototype" stage, but will compile programs if you are nice to it.<br />
<br />
<br />
=== Frege ===<br />
<br />
[https://github.com/Frege/frege Frege] is a pure functional programming language for the JVM in the spirit of Haskell. It enjoys a strong static type system with powerful type inference and non-strict - also known as lazy - evaluation.<br />
<br />
Frege programs are compiled to Java and run on the JVM.<br />
<br />
The similarity to Haskell is actually strong enough that many users call it "''a'' Haskell for the JVM".<br />
<br />
<br />
== Unmaintained ==<br />
<br />
=== Hugs ===<br />
[[Hugs]] is a small, portable Haskell interpreter written in C runs on almost any machine. Hugs is best used as a Haskell program development system: it boasts extremely fast source code interpretation, supports incremental interpretation, and has the convenience of an interactive interpreter (within which one can move from module to module to test different portions of a program). However, being an interpreter, it does not nearly match the run-time performance of, for example, GHC, nhc98, or HBC. Hugs 98 is conformant with Haskell 98. Available for all Unix platforms including Linux, DOS, Windows 3.x, and Win 32 (Windows 95, Win32s, NT) and Macintoshes. It has many libraries including Win32 libraries, a foreign interface mechanism to facilitate interoperability with C, and the Windows version has a graphical user interface called [[WinHugs]]. Explanations of some common Hugs error messages and their causes can be found on [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/errors.html Simon Thompson's page].<br />
<br />
=== nhc98 ===<br />
[http://www.haskell.org/nhc98/ nhc98] is a small, easy to install, standards-compliant Haskell 98 compiler. It works only on 32-bit machines. It provides some advanced kinds of heap profiles not found in any other Haskell compiler. It produces medium-fast code, and compilation is itself quite fast. The compiler stresses the saving of space, that is, it produces small programs requiring comparatively little space at runtime (and it is itself much smaller than the other compilers). It is available for all Unix-like platforms (including Mac OS X, Cygwin/Windows, Linux, Solaris, *BSD, AIX, HP-UX, Ultrix, IRIX, etc.). It is written in Haskell 98, but can be quickly and easily bootstrapped from C sources.<br />
<br />
=== York Haskell Compiler (YHC) ===<br />
[[Yhc]] is a fork of [http://www.haskell.org/nhc98/ nhc98], with the goals of being simpler, more portable, more efficient and integrating [[Hat]] support.<br />
<br />
=== [http://web.archive.org/web/20090815181116/http://www.cs.chalmers.se/~augustss/hbc/hbc.html '''HBI''' and '''HBC'''], Chalmers' Haskell Interpreter and Compiler ===<br />
The Chalmers Haskell-B compiler 0.9999.5c implements Haskell 98, as well as some extensions. It is written by Lennart Augustsson, and based on the classic LML compiler by Augustsson and Johnsson. The interpreter can also load code compiled with HBC. There has been no official release for the last few years and the support level is pretty low, but the compiler exists and can be used. Unfortunately the web-pages and the documentation has not been updated the last few years! You can download an unofficial [http://haskell.org/hbc/hbc-2004-06-29.src.tar.gz snapshot of the sources] and the corresponding [http://haskell.org/hbc/hbc-2004-06-29.bin-i386-linux.tar.gz x86 Linux binaries] (based on [http://www.cs.chalmers.se/pub/users/hallgren/Alfa/Haskell/ snapshots] from Thomas Hallgren and Magnus Carlsson). Other sources: [https://archive.org/details/haskell-b-compiler https://archive.org/details/haskell-b-compiler].<br />
<br />
=== Yale Haskell ===<br />
[http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/syntax/haskell/0.html Yale Haskell 2.05], an early implementation of Haskell in Lisp. See an early [http://groups.google.com/group/comp.lang.functional/msg/5b929ac0223a6212?dmode=source&hl=en release announcement]. More information is available on the [[Haskell Lisp]] page.<br />
<br />
=== The Brisk compiler ===<br />
A product of the [http://www.cs.bris.ac.uk/Research/LanguagesArchitecture/brisk.html BRISK project] at the University of Bristol investigating the further use of functional programming in systems-level software development. Version [http://www.cs.bris.ac.uk/~ian/Functional/brisk.tgz 0.08] partially implements an early version of Haskell.<br />
<br />
== Comparison of Implementations ==<br />
* Comparison of [https://web.archive.org/web/20160616121712/http://mirror.seize.it/report.html speed and memory usage (Web Archive)] of several Haskell implementations (February 2011). This page also shows how many samples compile/run correctly.<br />
<br />
* A [http://stackoverflow.com/questions/4084790/compilers-for-haskell stackoverflow discussion] of several implementations.<br />
<br />
<br />
[[Category:Implementations| ]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Implementations&diff=65243Implementations2022-08-06T01:41:14Z<p>Ppelleti: /* Disciple */ Now named Discus?</p>
<hr />
<div>Below you find a list of all Haskell implementations. The recommend way to install Haskell on your computer is through the the [http://hackage.haskell.org/platform/ Haskell Platform] or [[Stack|The Haskell Tool Stack]].<br />
<br />
<br />
== Haskell 2010 == <br />
<br />
=== Glasgow Haskell Compiler (GHC) ===<br />
[[GHC]] is an optimising compiler for Haskell, providing many language extensions. GHC is the de facto standard compiler if you want fast code. GHC is written in Haskell (plus extensions), and its size and complexity mean that it is less portable than Hugs, it runs more slowly, and it needs more memory. However, the programs it produces run ''much'' faster.<br />
<br />
There is also an interactive environment, GHCi, which is like Hugs but supports interactive loading of compiled code. GHC provides profiling for time and space, and supports concurrent and parallel programming. It is available for most common platforms, including Windows, Mac OS X, and several Unix variants (Linux, *BSD, Solaris).<br />
<br />
'''Outdated information'''<br />
<br />
The GHC team recommends installing the [[Haskell Platform]] to get GHC. (Note: While Windows users may have heard of [[MinGHC]], it has been superseded by [[Stack]].)<br />
<br />
Other methods of installation are listed at [[Distributions]].<br />
<br />
'''Newest information'''<br />
<br />
The Haskell Platform is deprecated. The currently [https://www.haskell.org/downloads/ recommended] way to install GHC and related tools is with [https://www.haskell.org/ghcup/ GHCup].<br />
<br />
=== Utrecht Haskell Compiler (UHC) ===<br />
[[UHC]] is a Haskell implementation from Utrecht University. UHC supports almost all Haskell 98 and Haskell 2010 features plus many experimental extensions. The compiler runs on Mac OS X, Windows (Cygwin), and various Unix flavors.<br />
<br />
Features include: Multiple backends, including a bytecode interpreter backend and a whole-program analysis backend based on GRIN. Experimental language extensions, some of which have not been implemented before.<br />
<br />
UHC is implemented using [[Attribute grammar|attribute grammars]], and due to an aspect-oriented internal organisation is ideally suited for experimenting with language extensions.<br />
<br />
On April 18, 2009 UHC was [http://www.cs.uu.nl/wiki/UHC/Announce announced] at the 5th Haskell Hackathon in Utrecht.<br />
<br />
<br />
=== LLVM Haskell Compiler (LHC) ===<br />
[https://github.com/Lemmih/lhc LHC] is a newly reborn project[http://lhc-compiler.blogspot.se/2014/11/the-new-lhc.html] to build a working Haskell 2010 compiler out of reusable blocks. <br />
<br />
<br />
== Haskell 98 ==<br />
<br />
=== Jhc Haskell Compiler ===<br />
[http://repetae.net/computer/jhc/ Jhc] is an experimental compiler with a goal of testing new optimization methods and exploring the design space of Haskell implementations.<br />
<br />
=== Helium ===<br />
[http://foswiki.cs.uu.nl/foswiki/Helium Helium] (link seems to be broken; try [https://github.com/Helium4Haskell/helium GitHub]) is a functional programming language and a compiler designed especially for teaching Haskell. Quality of the error messages has been the main concern both in the choice of the language features and in the implementation of the compiler. The language is a subset of the Haskell language. The most notable difference with Haskell is the absence of overloading. The compiler keeps track of a lot of information to produce informative messages.<br />
<br />
== Haskell Dialects ==<br />
<br />
=== Disciple ===<br />
[http://disciple.ouroborus.net Disciple] is a dialect of Haskell that uses strict evaluation as the default and supports destructive update of arbitrary data structures. Disciple includes region, effect and closure typing, and this extra information provides a handle on the operational behaviour of code that isn't available in other languages. Programs can be written in either a pure/functional or effectful/imperative style, and one of our goals is to provide both styles coherently in the same language. Our compiler is still in the "research prototype" stage, but will compile programs if you are nice to it.<br />
<br />
(Apparently Disciple has been renamed [http://www.discus-lang.org/ Discus].)<br />
<br />
=== Frege ===<br />
<br />
[https://github.com/Frege/frege Frege] is a pure functional programming language for the JVM in the spirit of Haskell. It enjoys a strong static type system with powerful type inference and non-strict - also known as lazy - evaluation.<br />
<br />
Frege programs are compiled to Java and run on the JVM.<br />
<br />
The similarity to Haskell is actually strong enough that many users call it "''a'' Haskell for the JVM".<br />
<br />
<br />
== Unmaintained ==<br />
<br />
=== Hugs ===<br />
[[Hugs]] is a small, portable Haskell interpreter written in C runs on almost any machine. Hugs is best used as a Haskell program development system: it boasts extremely fast source code interpretation, supports incremental interpretation, and has the convenience of an interactive interpreter (within which one can move from module to module to test different portions of a program). However, being an interpreter, it does not nearly match the run-time performance of, for example, GHC, nhc98, or HBC. Hugs 98 is conformant with Haskell 98. Available for all Unix platforms including Linux, DOS, Windows 3.x, and Win 32 (Windows 95, Win32s, NT) and Macintoshes. It has many libraries including Win32 libraries, a foreign interface mechanism to facilitate interoperability with C, and the Windows version has a graphical user interface called [[WinHugs]]. Explanations of some common Hugs error messages and their causes can be found on [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/errors.html Simon Thompson's page].<br />
<br />
=== nhc98 ===<br />
[http://www.haskell.org/nhc98/ nhc98] is a small, easy to install, standards-compliant Haskell 98 compiler. It works only on 32-bit machines. It provides some advanced kinds of heap profiles not found in any other Haskell compiler. It produces medium-fast code, and compilation is itself quite fast. The compiler stresses the saving of space, that is, it produces small programs requiring comparatively little space at runtime (and it is itself much smaller than the other compilers). It is available for all Unix-like platforms (including Mac OS X, Cygwin/Windows, Linux, Solaris, *BSD, AIX, HP-UX, Ultrix, IRIX, etc.). It is written in Haskell 98, but can be quickly and easily bootstrapped from C sources.<br />
<br />
=== York Haskell Compiler (YHC) ===<br />
[[Yhc]] is a fork of [http://www.haskell.org/nhc98/ nhc98], with the goals of being simpler, more portable, more efficient and integrating [[Hat]] support.<br />
<br />
=== [http://web.archive.org/web/20090815181116/http://www.cs.chalmers.se/~augustss/hbc/hbc.html '''HBI''' and '''HBC'''], Chalmers' Haskell Interpreter and Compiler ===<br />
The Chalmers Haskell-B compiler 0.9999.5c implements Haskell 98, as well as some extensions. It is written by Lennart Augustsson, and based on the classic LML compiler by Augustsson and Johnsson. The interpreter can also load code compiled with HBC. There has been no official release for the last few years and the support level is pretty low, but the compiler exists and can be used. Unfortunately the web-pages and the documentation has not been updated the last few years! You can download an unofficial [http://haskell.org/hbc/hbc-2004-06-29.src.tar.gz snapshot of the sources] and the corresponding [http://haskell.org/hbc/hbc-2004-06-29.bin-i386-linux.tar.gz x86 Linux binaries] (based on [http://www.cs.chalmers.se/pub/users/hallgren/Alfa/Haskell/ snapshots] from Thomas Hallgren and Magnus Carlsson). Other sources: [https://archive.org/details/haskell-b-compiler https://archive.org/details/haskell-b-compiler].<br />
<br />
=== Yale Haskell ===<br />
[http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/syntax/haskell/0.html Yale Haskell 2.05], an early implementation of Haskell in Lisp. See an early [http://groups.google.com/group/comp.lang.functional/msg/5b929ac0223a6212?dmode=source&hl=en release announcement]. More information is available on the [[Haskell Lisp]] page.<br />
<br />
=== The Brisk compiler ===<br />
A product of the [http://www.cs.bris.ac.uk/Research/LanguagesArchitecture/brisk.html BRISK project] at the University of Bristol investigating the further use of functional programming in systems-level software development. Version [http://www.cs.bris.ac.uk/~ian/Functional/brisk.tgz 0.08] partially implements an early version of Haskell.<br />
<br />
== Comparison of Implementations ==<br />
* Comparison of [https://web.archive.org/web/20160616121712/http://mirror.seize.it/report.html speed and memory usage (Web Archive)] of several Haskell implementations (February 2011). This page also shows how many samples compile/run correctly.<br />
<br />
* A [http://stackoverflow.com/questions/4084790/compilers-for-haskell stackoverflow discussion] of several implementations.<br />
<br />
<br />
[[Category:Implementations| ]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Implementations&diff=65242Implementations2022-08-06T01:34:31Z<p>Ppelleti: /* Glasgow Haskell Compiler (GHC) */ link to GHCup; Haskell Platform is deprecated</p>
<hr />
<div>Below you find a list of all Haskell implementations. The recommend way to install Haskell on your computer is through the the [http://hackage.haskell.org/platform/ Haskell Platform] or [[Stack|The Haskell Tool Stack]].<br />
<br />
<br />
== Haskell 2010 == <br />
<br />
=== Glasgow Haskell Compiler (GHC) ===<br />
[[GHC]] is an optimising compiler for Haskell, providing many language extensions. GHC is the de facto standard compiler if you want fast code. GHC is written in Haskell (plus extensions), and its size and complexity mean that it is less portable than Hugs, it runs more slowly, and it needs more memory. However, the programs it produces run ''much'' faster.<br />
<br />
There is also an interactive environment, GHCi, which is like Hugs but supports interactive loading of compiled code. GHC provides profiling for time and space, and supports concurrent and parallel programming. It is available for most common platforms, including Windows, Mac OS X, and several Unix variants (Linux, *BSD, Solaris).<br />
<br />
'''Outdated information'''<br />
<br />
The GHC team recommends installing the [[Haskell Platform]] to get GHC. (Note: While Windows users may have heard of [[MinGHC]], it has been superseded by [[Stack]].)<br />
<br />
Other methods of installation are listed at [[Distributions]].<br />
<br />
'''Newest information'''<br />
<br />
The Haskell Platform is deprecated. The currently [https://www.haskell.org/downloads/ recommended] way to install GHC and related tools is with [https://www.haskell.org/ghcup/ GHCup].<br />
<br />
=== Utrecht Haskell Compiler (UHC) ===<br />
[[UHC]] is a Haskell implementation from Utrecht University. UHC supports almost all Haskell 98 and Haskell 2010 features plus many experimental extensions. The compiler runs on Mac OS X, Windows (Cygwin), and various Unix flavors.<br />
<br />
Features include: Multiple backends, including a bytecode interpreter backend and a whole-program analysis backend based on GRIN. Experimental language extensions, some of which have not been implemented before.<br />
<br />
UHC is implemented using [[Attribute grammar|attribute grammars]], and due to an aspect-oriented internal organisation is ideally suited for experimenting with language extensions.<br />
<br />
On April 18, 2009 UHC was [http://www.cs.uu.nl/wiki/UHC/Announce announced] at the 5th Haskell Hackathon in Utrecht.<br />
<br />
<br />
=== LLVM Haskell Compiler (LHC) ===<br />
[https://github.com/Lemmih/lhc LHC] is a newly reborn project[http://lhc-compiler.blogspot.se/2014/11/the-new-lhc.html] to build a working Haskell 2010 compiler out of reusable blocks. <br />
<br />
<br />
== Haskell 98 ==<br />
<br />
=== Jhc Haskell Compiler ===<br />
[http://repetae.net/computer/jhc/ Jhc] is an experimental compiler with a goal of testing new optimization methods and exploring the design space of Haskell implementations.<br />
<br />
=== Helium ===<br />
[http://foswiki.cs.uu.nl/foswiki/Helium Helium] (link seems to be broken; try [https://github.com/Helium4Haskell/helium GitHub]) is a functional programming language and a compiler designed especially for teaching Haskell. Quality of the error messages has been the main concern both in the choice of the language features and in the implementation of the compiler. The language is a subset of the Haskell language. The most notable difference with Haskell is the absence of overloading. The compiler keeps track of a lot of information to produce informative messages.<br />
<br />
== Haskell Dialects ==<br />
<br />
=== Disciple ===<br />
[http://disciple.ouroborus.net Disciple] is a dialect of Haskell that uses strict evaluation as the default and supports destructive update of arbitrary data structures. Disciple includes region, effect and closure typing, and this extra information provides a handle on the operational behaviour of code that isn't available in other languages. Programs can be written in either a pure/functional or effectful/imperative style, and one of our goals is to provide both styles coherently in the same language. Our compiler is still in the "research prototype" stage, but will compile programs if you are nice to it.<br />
<br />
=== Frege ===<br />
<br />
[https://github.com/Frege/frege Frege] is a pure functional programming language for the JVM in the spirit of Haskell. It enjoys a strong static type system with powerful type inference and non-strict - also known as lazy - evaluation.<br />
<br />
Frege programs are compiled to Java and run on the JVM.<br />
<br />
The similarity to Haskell is actually strong enough that many users call it "''a'' Haskell for the JVM".<br />
<br />
<br />
== Unmaintained ==<br />
<br />
=== Hugs ===<br />
[[Hugs]] is a small, portable Haskell interpreter written in C runs on almost any machine. Hugs is best used as a Haskell program development system: it boasts extremely fast source code interpretation, supports incremental interpretation, and has the convenience of an interactive interpreter (within which one can move from module to module to test different portions of a program). However, being an interpreter, it does not nearly match the run-time performance of, for example, GHC, nhc98, or HBC. Hugs 98 is conformant with Haskell 98. Available for all Unix platforms including Linux, DOS, Windows 3.x, and Win 32 (Windows 95, Win32s, NT) and Macintoshes. It has many libraries including Win32 libraries, a foreign interface mechanism to facilitate interoperability with C, and the Windows version has a graphical user interface called [[WinHugs]]. Explanations of some common Hugs error messages and their causes can be found on [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/errors.html Simon Thompson's page].<br />
<br />
=== nhc98 ===<br />
[http://www.haskell.org/nhc98/ nhc98] is a small, easy to install, standards-compliant Haskell 98 compiler. It works only on 32-bit machines. It provides some advanced kinds of heap profiles not found in any other Haskell compiler. It produces medium-fast code, and compilation is itself quite fast. The compiler stresses the saving of space, that is, it produces small programs requiring comparatively little space at runtime (and it is itself much smaller than the other compilers). It is available for all Unix-like platforms (including Mac OS X, Cygwin/Windows, Linux, Solaris, *BSD, AIX, HP-UX, Ultrix, IRIX, etc.). It is written in Haskell 98, but can be quickly and easily bootstrapped from C sources.<br />
<br />
=== York Haskell Compiler (YHC) ===<br />
[[Yhc]] is a fork of [http://www.haskell.org/nhc98/ nhc98], with the goals of being simpler, more portable, more efficient and integrating [[Hat]] support.<br />
<br />
=== [http://web.archive.org/web/20090815181116/http://www.cs.chalmers.se/~augustss/hbc/hbc.html '''HBI''' and '''HBC'''], Chalmers' Haskell Interpreter and Compiler ===<br />
The Chalmers Haskell-B compiler 0.9999.5c implements Haskell 98, as well as some extensions. It is written by Lennart Augustsson, and based on the classic LML compiler by Augustsson and Johnsson. The interpreter can also load code compiled with HBC. There has been no official release for the last few years and the support level is pretty low, but the compiler exists and can be used. Unfortunately the web-pages and the documentation has not been updated the last few years! You can download an unofficial [http://haskell.org/hbc/hbc-2004-06-29.src.tar.gz snapshot of the sources] and the corresponding [http://haskell.org/hbc/hbc-2004-06-29.bin-i386-linux.tar.gz x86 Linux binaries] (based on [http://www.cs.chalmers.se/pub/users/hallgren/Alfa/Haskell/ snapshots] from Thomas Hallgren and Magnus Carlsson). Other sources: [https://archive.org/details/haskell-b-compiler https://archive.org/details/haskell-b-compiler].<br />
<br />
=== Yale Haskell ===<br />
[http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/syntax/haskell/0.html Yale Haskell 2.05], an early implementation of Haskell in Lisp. See an early [http://groups.google.com/group/comp.lang.functional/msg/5b929ac0223a6212?dmode=source&hl=en release announcement]. More information is available on the [[Haskell Lisp]] page.<br />
<br />
=== The Brisk compiler ===<br />
A product of the [http://www.cs.bris.ac.uk/Research/LanguagesArchitecture/brisk.html BRISK project] at the University of Bristol investigating the further use of functional programming in systems-level software development. Version [http://www.cs.bris.ac.uk/~ian/Functional/brisk.tgz 0.08] partially implements an early version of Haskell.<br />
<br />
== Comparison of Implementations ==<br />
* Comparison of [https://web.archive.org/web/20160616121712/http://mirror.seize.it/report.html speed and memory usage (Web Archive)] of several Haskell implementations (February 2011). This page also shows how many samples compile/run correctly.<br />
<br />
* A [http://stackoverflow.com/questions/4084790/compilers-for-haskell stackoverflow discussion] of several implementations.<br />
<br />
<br />
[[Category:Implementations| ]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Implementations&diff=65241Implementations2022-08-06T01:25:11Z<p>Ppelleti: /* Helium */ provide GitHub link; foswiki does not exist</p>
<hr />
<div>Below you find a list of all Haskell implementations. The recommend way to install Haskell on your computer is through the the [http://hackage.haskell.org/platform/ Haskell Platform] or [[Stack|The Haskell Tool Stack]].<br />
<br />
<br />
== Haskell 2010 == <br />
<br />
=== Glasgow Haskell Compiler (GHC) ===<br />
[[GHC]] is an optimising compiler for Haskell, providing many language extensions. GHC is the de facto standard compiler if you want fast code. GHC is written in Haskell (plus extensions), and its size and complexity mean that it is less portable than Hugs, it runs more slowly, and it needs more memory. However, the programs it produces run ''much'' faster.<br />
<br />
There is also an interactive environment, GHCi, which is like Hugs but supports interactive loading of compiled code. GHC provides profiling for time and space, and supports concurrent and parallel programming. It is available for most common platforms, including Windows, Mac OS X, and several Unix variants (Linux, *BSD, Solaris).<br />
<br />
The GHC team recommends installing the [[Haskell Platform]] to get GHC. (Note: While Windows users may have heard of [[MinGHC]], it has been superseded by [[Stack]].)<br />
<br />
Other methods of installation are listed at [[Distributions]].<br />
<br />
=== Utrecht Haskell Compiler (UHC) ===<br />
[[UHC]] is a Haskell implementation from Utrecht University. UHC supports almost all Haskell 98 and Haskell 2010 features plus many experimental extensions. The compiler runs on Mac OS X, Windows (Cygwin), and various Unix flavors.<br />
<br />
Features include: Multiple backends, including a bytecode interpreter backend and a whole-program analysis backend based on GRIN. Experimental language extensions, some of which have not been implemented before.<br />
<br />
UHC is implemented using [[Attribute grammar|attribute grammars]], and due to an aspect-oriented internal organisation is ideally suited for experimenting with language extensions.<br />
<br />
On April 18, 2009 UHC was [http://www.cs.uu.nl/wiki/UHC/Announce announced] at the 5th Haskell Hackathon in Utrecht.<br />
<br />
<br />
=== LLVM Haskell Compiler (LHC) ===<br />
[https://github.com/Lemmih/lhc LHC] is a newly reborn project[http://lhc-compiler.blogspot.se/2014/11/the-new-lhc.html] to build a working Haskell 2010 compiler out of reusable blocks. <br />
<br />
<br />
== Haskell 98 ==<br />
<br />
=== Jhc Haskell Compiler ===<br />
[http://repetae.net/computer/jhc/ Jhc] is an experimental compiler with a goal of testing new optimization methods and exploring the design space of Haskell implementations.<br />
<br />
=== Helium ===<br />
[http://foswiki.cs.uu.nl/foswiki/Helium Helium] (link seems to be broken; try [https://github.com/Helium4Haskell/helium GitHub]) is a functional programming language and a compiler designed especially for teaching Haskell. Quality of the error messages has been the main concern both in the choice of the language features and in the implementation of the compiler. The language is a subset of the Haskell language. The most notable difference with Haskell is the absence of overloading. The compiler keeps track of a lot of information to produce informative messages.<br />
<br />
== Haskell Dialects ==<br />
<br />
=== Disciple ===<br />
[http://disciple.ouroborus.net Disciple] is a dialect of Haskell that uses strict evaluation as the default and supports destructive update of arbitrary data structures. Disciple includes region, effect and closure typing, and this extra information provides a handle on the operational behaviour of code that isn't available in other languages. Programs can be written in either a pure/functional or effectful/imperative style, and one of our goals is to provide both styles coherently in the same language. Our compiler is still in the "research prototype" stage, but will compile programs if you are nice to it.<br />
<br />
=== Frege ===<br />
<br />
[https://github.com/Frege/frege Frege] is a pure functional programming language for the JVM in the spirit of Haskell. It enjoys a strong static type system with powerful type inference and non-strict - also known as lazy - evaluation.<br />
<br />
Frege programs are compiled to Java and run on the JVM.<br />
<br />
The similarity to Haskell is actually strong enough that many users call it "''a'' Haskell for the JVM".<br />
<br />
<br />
== Unmaintained ==<br />
<br />
=== Hugs ===<br />
[[Hugs]] is a small, portable Haskell interpreter written in C runs on almost any machine. Hugs is best used as a Haskell program development system: it boasts extremely fast source code interpretation, supports incremental interpretation, and has the convenience of an interactive interpreter (within which one can move from module to module to test different portions of a program). However, being an interpreter, it does not nearly match the run-time performance of, for example, GHC, nhc98, or HBC. Hugs 98 is conformant with Haskell 98. Available for all Unix platforms including Linux, DOS, Windows 3.x, and Win 32 (Windows 95, Win32s, NT) and Macintoshes. It has many libraries including Win32 libraries, a foreign interface mechanism to facilitate interoperability with C, and the Windows version has a graphical user interface called [[WinHugs]]. Explanations of some common Hugs error messages and their causes can be found on [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/errors.html Simon Thompson's page].<br />
<br />
=== nhc98 ===<br />
[http://www.haskell.org/nhc98/ nhc98] is a small, easy to install, standards-compliant Haskell 98 compiler. It works only on 32-bit machines. It provides some advanced kinds of heap profiles not found in any other Haskell compiler. It produces medium-fast code, and compilation is itself quite fast. The compiler stresses the saving of space, that is, it produces small programs requiring comparatively little space at runtime (and it is itself much smaller than the other compilers). It is available for all Unix-like platforms (including Mac OS X, Cygwin/Windows, Linux, Solaris, *BSD, AIX, HP-UX, Ultrix, IRIX, etc.). It is written in Haskell 98, but can be quickly and easily bootstrapped from C sources.<br />
<br />
=== York Haskell Compiler (YHC) ===<br />
[[Yhc]] is a fork of [http://www.haskell.org/nhc98/ nhc98], with the goals of being simpler, more portable, more efficient and integrating [[Hat]] support.<br />
<br />
=== [http://web.archive.org/web/20090815181116/http://www.cs.chalmers.se/~augustss/hbc/hbc.html '''HBI''' and '''HBC'''], Chalmers' Haskell Interpreter and Compiler ===<br />
The Chalmers Haskell-B compiler 0.9999.5c implements Haskell 98, as well as some extensions. It is written by Lennart Augustsson, and based on the classic LML compiler by Augustsson and Johnsson. The interpreter can also load code compiled with HBC. There has been no official release for the last few years and the support level is pretty low, but the compiler exists and can be used. Unfortunately the web-pages and the documentation has not been updated the last few years! You can download an unofficial [http://haskell.org/hbc/hbc-2004-06-29.src.tar.gz snapshot of the sources] and the corresponding [http://haskell.org/hbc/hbc-2004-06-29.bin-i386-linux.tar.gz x86 Linux binaries] (based on [http://www.cs.chalmers.se/pub/users/hallgren/Alfa/Haskell/ snapshots] from Thomas Hallgren and Magnus Carlsson). Other sources: [https://archive.org/details/haskell-b-compiler https://archive.org/details/haskell-b-compiler].<br />
<br />
=== Yale Haskell ===<br />
[http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/syntax/haskell/0.html Yale Haskell 2.05], an early implementation of Haskell in Lisp. See an early [http://groups.google.com/group/comp.lang.functional/msg/5b929ac0223a6212?dmode=source&hl=en release announcement]. More information is available on the [[Haskell Lisp]] page.<br />
<br />
=== The Brisk compiler ===<br />
A product of the [http://www.cs.bris.ac.uk/Research/LanguagesArchitecture/brisk.html BRISK project] at the University of Bristol investigating the further use of functional programming in systems-level software development. Version [http://www.cs.bris.ac.uk/~ian/Functional/brisk.tgz 0.08] partially implements an early version of Haskell.<br />
<br />
== Comparison of Implementations ==<br />
* Comparison of [https://web.archive.org/web/20160616121712/http://mirror.seize.it/report.html speed and memory usage (Web Archive)] of several Haskell implementations (February 2011). This page also shows how many samples compile/run correctly.<br />
<br />
* A [http://stackoverflow.com/questions/4084790/compilers-for-haskell stackoverflow discussion] of several implementations.<br />
<br />
<br />
[[Category:Implementations| ]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=HaskellWiki:About&diff=62782HaskellWiki:About2019-02-19T15:58:52Z<p>Ppelleti: /* Reporting Bugs */ discourage filing bugs about wiki content</p>
<hr />
<div>The HaskellWiki is a communication means for people interested in the programming language [[Haskell]].<br />
<br />
See the [[HaskellWiki:Contributing|contribute]] page if you want to edit or add new content.<br />
<br />
== History ==<br />
The predecessor to the HaskellWiki was HaWiki, born on 15 April, 2003. HaWiki was installed by KeithWansbrough, and has been maintained by ShaeErisson. In October 2006, it retired from active service.<br />
<br />
== Reporting Bugs ==<br />
<br />
If you run across bugs in the ''configuration'' of the HaskellWiki (e. g. [https://github.com/haskell/haskell-wiki-configuration/issues/1 diffs aren't showing up] or [https://github.com/haskell/haskell-wiki-configuration/issues/5 you're seeing disturbing error messages]), then please [https://github.com/haskell/haskell-wiki-configuration/issues file an issue]. This is ''only'' for configuration bugs. If you find errors in the ''content'' of the wiki, please just [[HaskellWiki:Contributing|fix them yourself]]. Thanks!</div>Ppelletihttps://wiki.haskell.org/index.php?title=Sandbox&diff=61538Sandbox2017-02-14T08:43:39Z<p>Ppelleti: /* Single Quote */ more syntax highlighting</p>
<hr />
<div>''Feel free to edit as you wish on this page. It is here for you to experiment with WIKI edit syntax.''<br />
<br />
==fooling around==<br />
{{Standard class|State|module=Control.Monad.State.Lazy|module-doc=Control.Monad.State.Lazy|package=test}}<br />
<br />
{| border=0 align=right cellpadding=4 cellspacing=0 style="border:1px #aaa solid"<br />
| <TT>import [http://www.haskell.org/ghc/docs/latest/html/testp/testmd.html testm]</TT><br />
|}<br />
TADA! [http://google.com this is a link to google, surprisingly]<br />
<br />
[[User:Siers|Siers]] Fri Jun 27 02:36:37 EEST 2014<br />
<br />
==section==<br />
[[Sandbox#secton]]<br><br />
[[#Links]]<br><br />
<br />
<br />
<br />
--[[User:Lars|Lars]] 11:14, 27 July 2009 (UTC)<br />
----<br />
<math>Insert formula here</math>[[Media:Example.ogg]][[Image:Example.jpg]]<br />
== Headline text ==<br />
''Italic text'''''Bold text'''<br />
{| border="1"<br />
|-<br />
|Pavillon || Uge || Uge <br />
|}<br />
<br />
Matrix:<br />
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & 4\end{matrix} \right]</math><br />
<br />
Embedded matrix:<br />
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & \left[ \begin{matrix}5 & 6 \\ 7 & 8\end{matrix}\right] \end{matrix} \right]</math><br />
<br />
== Links ==<br />
<br />
An [[internal]] link. To not exists page [[abcd]]. To exists page [[Haskell]]<br />
<br />
=== External ===<br />
http://cs.pdx.edu/<br />
:<br />
http://cs.pdx.edu/~dick/HaskellSemantics/jpf05.pdf<br />
:<br />
http://cs.pdx.edu/~dick/HaskellSemantics/Haskell98.pdf<br />
<br />
There is no appearance difference between dead link [http://deadlink.local dead] and live link [http://wiki.haskell.org live]<br />
<br />
Text taken from http://hpaste.org/3881: this wiki's syntax highlight at least does not garble the source, unlike hpaste's highlight.<br />
<br />
An [http://www.haskell.org external link] using text instead of the raw link address.<br />
<br />
<haskell><br />
module Main where<br />
<br />
import Prelude hiding (putStrLn, print)<br />
import System.IO.UTF8<br />
import Data.List (intersperse, find)<br />
<br />
type Персонаж = String<br />
type Персонажи = [Персонаж]<br />
<br />
едоки :: Персонажи<br />
едоки = [ "дедка", "бабка", "внучка", "жучка", "кошка", "мышка" ]<br />
<br />
подходы :: [ Персонажи ]<br />
подходы = scanl позвать [] едоки<br />
where позвать тянущие подмога = подмога:тянущие<br />
<br />
построились :: Персонажи -> [ (Персонаж, Персонаж) ]<br />
построились едоки = zip едоки ("репка":едоки)<br />
<br />
диспозиции = map (построились.reverse) подходы<br />
<br />
описать [] = "Посадил дед репку ..."<br />
описать диспозиция = <br />
unwords ["Взялись:"<br />
, concat $ intersperse ", " $ map за диспозиция<br />
, ". Тянут-потянут -- " ++ result<br />
]<br />
where <br />
за (кто,кого) = кто ++ " за " ++ винительный_падеж кого<br />
винительный_падеж ы = init ы ++ "у"<br />
result = case find ((=="мышка").fst) диспозиция of<br />
Just _ -> "вытянули репку!"<br />
Nothing -> "вытянуть не могут!"<br />
<br />
main = mapM_ putStrLn $ map описать диспозиции</haskell><br />
<br />
== Section ==<br />
=== Subsection ===<br />
==== Subsubsection ====<br />
<br />
huhu<br />
<br />
===== Subsubsubsection =====<br />
<br />
= tables =<br />
== basic table ==<br />
<br />
{|<br />
|-<br />
! Header 1<br />
! Header 2<br />
! Header 3<br />
|-<br />
| row 1, cell 1<br />
| row 1, cell 2<br />
| row 1, cell 3<br />
|-<br />
| row 2, cell 1<br />
| row 2, cell 2<br />
| row 2, cell 3<br />
|}<br />
<br />
=Single Quote=<br />
<br />
https://github.com/ppelleti/haskell-wiki-bugs/issues/6<br />
<br />
This seems to be fixed.<br />
<br />
<haskell><br />
myLast :: [a] -> a<br />
myLast [] = error "No end for empty lists!"<br />
myLast [x] = x<br />
myLast (_:xs) = myLast xs<br />
<br />
myLast' = foldr1 (const id)<br />
<br />
-- Prelude> const 1 2<br />
-- 1<br />
-- Prelude> (flip const) 1 2<br />
-- 2<br />
myLast'' = foldr1 (flip const)<br />
<br />
myLast''' = head . reverse<br />
<br />
myLast'''' = foldl1 (curry snd)<br />
<br />
myLast''''' [] = error "No end for empty lists!" <br />
myLast''''' x = x !! (length x -1)<br />
<br />
</haskell><br />
<br />
haskelll code without syntax highlight (no <code>'</code> problem)<br />
<syntaxhighlight lang="text" line='line'><br />
<br />
-- import Prelude<br />
import Data.List<br />
import Data.Function<br />
<br />
main :: IO ()<br />
main = do<br />
let xs = [(8,2),(3,2),(3,1),(10,2),(10,6)] :: [(Int,Int)]<br />
print xs<br />
let sortXs' = sort xs<br />
print sortXs'<br />
<br />
</syntaxhighlight><br />
<br />
=Another syntax highlighting example=<br />
<br />
<haskell><br />
import Control.Applicative<br />
import Data.Bits<br />
import Data.IORef<br />
import Data.Word<br />
<br />
ioDirA, iPolA, ioCon, gpPuA, gpioA, gpioB, olatA :: Word8<br />
<br />
readReg16 :: ReadFunc -> Word8 -> IO Word16<br />
readReg16 rf reg = word8sToWord16 <$> rf reg 2<br />
<br />
data RomCode = RomA00 | RomA02<br />
deriving (Eq, Ord, Show, Read, Bounded, Enum)<br />
</haskell></div>Ppelletihttps://wiki.haskell.org/index.php?title=Sandbox&diff=61537Sandbox2017-02-14T08:33:57Z<p>Ppelleti: /* Single Quote */ touch page to see if that helps</p>
<hr />
<div>''Feel free to edit as you wish on this page. It is here for you to experiment with WIKI edit syntax.''<br />
<br />
==fooling around==<br />
{{Standard class|State|module=Control.Monad.State.Lazy|module-doc=Control.Monad.State.Lazy|package=test}}<br />
<br />
{| border=0 align=right cellpadding=4 cellspacing=0 style="border:1px #aaa solid"<br />
| <TT>import [http://www.haskell.org/ghc/docs/latest/html/testp/testmd.html testm]</TT><br />
|}<br />
TADA! [http://google.com this is a link to google, surprisingly]<br />
<br />
[[User:Siers|Siers]] Fri Jun 27 02:36:37 EEST 2014<br />
<br />
==section==<br />
[[Sandbox#secton]]<br><br />
[[#Links]]<br><br />
<br />
<br />
<br />
--[[User:Lars|Lars]] 11:14, 27 July 2009 (UTC)<br />
----<br />
<math>Insert formula here</math>[[Media:Example.ogg]][[Image:Example.jpg]]<br />
== Headline text ==<br />
''Italic text'''''Bold text'''<br />
{| border="1"<br />
|-<br />
|Pavillon || Uge || Uge <br />
|}<br />
<br />
Matrix:<br />
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & 4\end{matrix} \right]</math><br />
<br />
Embedded matrix:<br />
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & \left[ \begin{matrix}5 & 6 \\ 7 & 8\end{matrix}\right] \end{matrix} \right]</math><br />
<br />
== Links ==<br />
<br />
An [[internal]] link. To not exists page [[abcd]]. To exists page [[Haskell]]<br />
<br />
=== External ===<br />
http://cs.pdx.edu/<br />
:<br />
http://cs.pdx.edu/~dick/HaskellSemantics/jpf05.pdf<br />
:<br />
http://cs.pdx.edu/~dick/HaskellSemantics/Haskell98.pdf<br />
<br />
There is no appearance difference between dead link [http://deadlink.local dead] and live link [http://wiki.haskell.org live]<br />
<br />
Text taken from http://hpaste.org/3881: this wiki's syntax highlight at least does not garble the source, unlike hpaste's highlight.<br />
<br />
An [http://www.haskell.org external link] using text instead of the raw link address.<br />
<br />
<haskell><br />
module Main where<br />
<br />
import Prelude hiding (putStrLn, print)<br />
import System.IO.UTF8<br />
import Data.List (intersperse, find)<br />
<br />
type Персонаж = String<br />
type Персонажи = [Персонаж]<br />
<br />
едоки :: Персонажи<br />
едоки = [ "дедка", "бабка", "внучка", "жучка", "кошка", "мышка" ]<br />
<br />
подходы :: [ Персонажи ]<br />
подходы = scanl позвать [] едоки<br />
where позвать тянущие подмога = подмога:тянущие<br />
<br />
построились :: Персонажи -> [ (Персонаж, Персонаж) ]<br />
построились едоки = zip едоки ("репка":едоки)<br />
<br />
диспозиции = map (построились.reverse) подходы<br />
<br />
описать [] = "Посадил дед репку ..."<br />
описать диспозиция = <br />
unwords ["Взялись:"<br />
, concat $ intersperse ", " $ map за диспозиция<br />
, ". Тянут-потянут -- " ++ result<br />
]<br />
where <br />
за (кто,кого) = кто ++ " за " ++ винительный_падеж кого<br />
винительный_падеж ы = init ы ++ "у"<br />
result = case find ((=="мышка").fst) диспозиция of<br />
Just _ -> "вытянули репку!"<br />
Nothing -> "вытянуть не могут!"<br />
<br />
main = mapM_ putStrLn $ map описать диспозиции</haskell><br />
<br />
== Section ==<br />
=== Subsection ===<br />
==== Subsubsection ====<br />
<br />
huhu<br />
<br />
===== Subsubsubsection =====<br />
<br />
= tables =<br />
== basic table ==<br />
<br />
{|<br />
|-<br />
! Header 1<br />
! Header 2<br />
! Header 3<br />
|-<br />
| row 1, cell 1<br />
| row 1, cell 2<br />
| row 1, cell 3<br />
|-<br />
| row 2, cell 1<br />
| row 2, cell 2<br />
| row 2, cell 3<br />
|}<br />
<br />
=Single Quote=<br />
<br />
https://github.com/ppelleti/haskell-wiki-bugs/issues/6<br />
<br />
Is this fixed?<br />
<br />
<haskell><br />
myLast :: [a] -> a<br />
myLast [] = error "No end for empty lists!"<br />
myLast [x] = x<br />
myLast (_:xs) = myLast xs<br />
<br />
myLast' = foldr1 (const id)<br />
<br />
-- Prelude> const 1 2<br />
-- 1<br />
-- Prelude> (flip const) 1 2<br />
-- 2<br />
myLast'' = foldr1 (flip const)<br />
<br />
myLast''' = head . reverse<br />
<br />
myLast'''' = foldl1 (curry snd)<br />
<br />
myLast''''' [] = error "No end for empty lists!" <br />
myLast''''' x = x !! (length x -1)<br />
<br />
</haskell><br />
<br />
haskelll code without syntax highlight (no <code>'</code> problem)<br />
<syntaxhighlight lang="text" line='line'><br />
<br />
-- import Prelude<br />
import Data.List<br />
import Data.Function<br />
<br />
main :: IO ()<br />
main = do<br />
let xs = [(8,2),(3,2),(3,1),(10,2),(10,6)] :: [(Int,Int)]<br />
print xs<br />
let sortXs' = sort xs<br />
print sortXs'<br />
<br />
</syntaxhighlight></div>Ppelletihttps://wiki.haskell.org/index.php?title=Raspberry_Pi&diff=61512Raspberry Pi2017-02-08T08:31:51Z<p>Ppelleti: /* Links */ A script to install Stack on Raspbian</p>
<hr />
<div>{{Stub}}<br />
<br />
== Introduction ==<br />
<br />
Raspberry Pi is an [[ARM]] based single-board computer, developed for educational purposes, costing USD 25. For more details, see [http://en.wikipedia.org/wiki/Raspberry_Pi the Wikipedia article about Raspberry Pi], or the [http://www.raspberrypi.org/faqs FAQ list].<br />
<br />
[[Image:Raspberry_Pi_Beta_Board.jpg]]<br />
<br />
== Links == <br />
<br />
* [https://github.com/ku-fpg/raspberry-pi/wiki/GHC-Cross-Compiler-for-Raspberry-Pi GHC Cross Compiler for Raspberry Pi]<br />
<br />
* [http://www.reddit.com/r/haskell/comments/u7cwv/some_observationsproblems_of_getting_haskellghc/ Some observations/problems of getting Haskell/GHC running on the Raspberry Pi] (Reddit)<br />
<br />
* [http://www.raspberrypi.org/ The official Raspberry Pi site]<br />
<br />
* [http://alenribic.com/posts/2012-08-06-running-haskell-on-raspberry-pi.html Running Haskell on Raspberry Pi] (blog)<br />
<br />
* [http://alenribic.com/posts/2012-08-17-raspberry-pi-in-a-haskell-cloud.html Raspberry Pi in a Haskell Cloud] (blog)<br />
<br />
* [http://www.mail-archive.com/haskell-cafe@haskell.org/msg99529.html Re: <nowiki>[Haskell-cafe]</nowiki> Haskell (GHC 7) on ARM]<br />
<br />
* [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=34&t=6655 Haskell/GHC observations on the official Raspberry Pi forum]<br />
<br />
* [https://haskellembedded.github.io/posts/2015-12-15-arm.html Guide to Haskell ARM compilers, cross-compilers, and QEMU]<br />
<br />
* [https://gist.github.com/jamesthompson/7730209b2b154bd0a182e6fe945a2838 A script to install Stack on Raspbian]<br />
<br />
== GHC Status ==<br />
<br />
Of the "official" images currently available from the [http://www.raspberrypi.org/downloads Raspberry Pi Downloads] page, the following versions of GHC are available<br />
<br />
* Arch Linux - 6.12.3-1<br />
* Debian Squeeze - [http://packages.debian.org/stable/haskell/ghc6 6.12.1-13]<br />
* Debian Wheezy - [http://packages.debian.org/wheezy/ghc 7.4.1-3]<br />
* Raspbian Jessie - 7.6.3-21+rpi1<br />
<br />
'''Note:''' GHCi does not work on ARM with older versions, but it has become available in GHC 7.8. See [http://www.haskell.org/pipermail/haskell-cafe/2013-December/111825.html this post on haskell-cafe] for the status as of December 2013. [https://stackoverflow.com/questions/29379706/ghci-on-raspberry-pi-2 Success with 7.8 on a Raspberry Pi 2.]<br />
<br />
There seemed to be a point where GHCi was [http://www.haskell.org/pipermail/haskell-cafe/2012-June/101704.html merged into version 7.4.2.], and it may still be possible to install it in an experimental manner, but it is not (currently) available in the Debian Raspberry Pi repository. [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=34&t=6655 Here is a discussion thread wherein djhuk describes] compiling and installing GHC-7.4.2 via QEMU to the Raspberry Pi, with incomplete GHCi functionality.<br />
<br />
To build a cross-compiler from Linux to Raspberry Pi (running Raspbian), see the [https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/RaspberryPi GHC Trac].<br />
<br />
== Libraries ==<br />
<br />
* wiringPi <br />
: A Haskell binding to the wiringPi library, for using GPIO on the Raspberry Pi<br />
:: [https://hackage.haskell.org/package/wiringPi The package on Hackage]<br />
:: [https://github.com/ppelleti/hs-wiringPi On GitHub]<br />
:: [https://mail.haskell.org/pipermail/haskell-cafe/2017-January/125909.html The announcement]<br />
<br />
== Current Issues ==<br />
<br />
The main issue encountered so far is the memory limitations of the devices with 256 MB RAM; [[GHC]] will execute fine, but problems will start to arise when using [[cabal-install]] to install new libraries, especially ones with lots of dependencies. (Recent model B boards have 512 MB on board [http://www.raspberrypi.org/archives/2180], Raspberry Pi 2 Model B boards have 1GB on board.)<br />
<br />
Potential solutions to this problem have been suggested, including using [http://wiki.qemu.org/Main_Page QEMU] on a more powerful system and thus compiling your application there and copying the resulting binary across to your Raspberry Pi<br />
<br />
== Books ==<br />
* Heitz, Ryan [http://www.manning.com/heitz/ Hello Raspberry Pi!]. Manning Publications (2015). p.p. 225. ISBN 9781617292453<br />
<br />
== See also ==<br />
<br />
* [[Arduino]]<br />
<br />
* [[Robotics]]<br />
<br />
* [[ARM]]<br />
<br />
* [[iPhone]]<br />
<br />
<br />
[[Category:Platforms]]<br />
[[Category:Robotics]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Sandbox&diff=61444Sandbox2017-01-17T17:48:41Z<p>Ppelleti: syntax highlighting bug</p>
<hr />
<div>''Feel free to edit as you wish on this page. It is here for you to experiment with WIKI edit syntax.''<br />
<br />
==fooling around==<br />
{{Standard class|State|module=Control.Monad.State.Lazy|module-doc=Control.Monad.State.Lazy|package=test}}<br />
<br />
{| border=0 align=right cellpadding=4 cellspacing=0 style="border:1px #aaa solid"<br />
| <TT>import [http://www.haskell.org/ghc/docs/latest/html/testp/testmd.html testm]</TT><br />
|}<br />
TADA! [http://google.com this is a link to google, surprisingly]<br />
<br />
[[User:Siers|Siers]] Fri Jun 27 02:36:37 EEST 2014<br />
<br />
==section==<br />
[[Sandbox#secton]]<br><br />
[[#Links]]<br><br />
<br />
<br />
<br />
--[[User:Lars|Lars]] 11:14, 27 July 2009 (UTC)<br />
----<br />
<math>Insert formula here</math>[[Media:Example.ogg]][[Image:Example.jpg]]<br />
== Headline text ==<br />
''Italic text'''''Bold text'''<br />
{| border="1"<br />
|-<br />
|Pavillon || Uge || Uge <br />
|}<br />
<br />
Matrix:<br />
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & 4\end{matrix} \right]</math><br />
<br />
Embedded matrix:<br />
:<math>\left[ \begin{matrix}1 & 2 \\ 3 & \left[ \begin{matrix}5 & 6 \\ 7 & 8\end{matrix}\right] \end{matrix} \right]</math><br />
<br />
== Links ==<br />
<br />
An [[internal]] link. To not exists page [[abcd]]. To exists page [[Haskell]]<br />
<br />
=== External ===<br />
http://cs.pdx.edu/<br />
:<br />
http://cs.pdx.edu/~dick/HaskellSemantics/jpf05.pdf<br />
:<br />
http://cs.pdx.edu/~dick/HaskellSemantics/Haskell98.pdf<br />
<br />
There is no appearance difference between dead link [http://deadlink.local dead] and live link [http://wiki.haskell.org live]<br />
<br />
Text taken from http://hpaste.org/3881: this wiki's syntax highlight at least does not garble the source, unlike hpaste's highlight.<br />
<br />
An [http://www.haskell.org external link] using text instead of the raw link address.<br />
<br />
<haskell><br />
module Main where<br />
<br />
import Prelude hiding (putStrLn, print)<br />
import System.IO.UTF8<br />
import Data.List (intersperse, find)<br />
<br />
type Персонаж = String<br />
type Персонажи = [Персонаж]<br />
<br />
едоки :: Персонажи<br />
едоки = [ "дедка", "бабка", "внучка", "жучка", "кошка", "мышка" ]<br />
<br />
подходы :: [ Персонажи ]<br />
подходы = scanl позвать [] едоки<br />
where позвать тянущие подмога = подмога:тянущие<br />
<br />
построились :: Персонажи -> [ (Персонаж, Персонаж) ]<br />
построились едоки = zip едоки ("репка":едоки)<br />
<br />
диспозиции = map (построились.reverse) подходы<br />
<br />
описать [] = "Посадил дед репку ..."<br />
описать диспозиция = <br />
unwords ["Взялись:"<br />
, concat $ intersperse ", " $ map за диспозиция<br />
, ". Тянут-потянут -- " ++ result<br />
]<br />
where <br />
за (кто,кого) = кто ++ " за " ++ винительный_падеж кого<br />
винительный_падеж ы = init ы ++ "у"<br />
result = case find ((=="мышка").fst) диспозиция of<br />
Just _ -> "вытянули репку!"<br />
Nothing -> "вытянуть не могут!"<br />
<br />
main = mapM_ putStrLn $ map описать диспозиции</haskell><br />
<br />
== Section ==<br />
=== Subsection ===<br />
==== Subsubsection ====<br />
<br />
huhu<br />
<br />
===== Subsubsubsection =====<br />
<br />
= tables =<br />
== basic table ==<br />
<br />
{|<br />
|-<br />
! Header 1<br />
! Header 2<br />
! Header 3<br />
|-<br />
| row 1, cell 1<br />
| row 1, cell 2<br />
| row 1, cell 3<br />
|-<br />
| row 2, cell 1<br />
| row 2, cell 2<br />
| row 2, cell 3<br />
|}<br />
<br />
=Single Quote=<br />
<br />
https://github.com/ppelleti/haskell-wiki-bugs/issues/6<br />
<br />
<haskell><br />
myLast :: [a] -> a<br />
myLast [] = error "No end for empty lists!"<br />
myLast [x] = x<br />
myLast (_:xs) = myLast xs<br />
<br />
myLast' = foldr1 (const id)<br />
<br />
-- Prelude> const 1 2<br />
-- 1<br />
-- Prelude> (flip const) 1 2<br />
-- 2<br />
myLast'' = foldr1 (flip const)<br />
<br />
myLast''' = head . reverse<br />
<br />
myLast'''' = foldl1 (curry snd)<br />
<br />
myLast''''' [] = error "No end for empty lists!" <br />
myLast''''' x = x !! (length x -1)<br />
<br />
</haskell></div>Ppelletihttps://wiki.haskell.org/index.php?title=HaskellWiki:About&diff=61264HaskellWiki:About2016-11-03T21:13:22Z<p>Ppelleti: Link to issue tracker</p>
<hr />
<div>The HaskellWiki is a communication means for people interested in the programming language [[Haskell]].<br />
<br />
See the [[HaskellWiki:Contributing|contribute]] page if you want to edit or add new content.<br />
<br />
== History ==<br />
The predecessor to the HaskellWiki was HaWiki, born on 15 April, 2003. HaWiki was installed by KeithWansbrough, and has been maintained by ShaeErisson. In October 2006, it retired from active service.<br />
<br />
== Reporting Bugs ==<br />
<br />
If you run across bugs on the HaskellWiki (e. g. [https://github.com/ppelleti/haskell-wiki-bugs/issues/1 diffs aren't showing up] or [https://github.com/ppelleti/haskell-wiki-bugs/issues/5 you're seeing disturbing error messages]), then please [https://github.com/ppelleti/haskell-wiki-bugs/issues file an issue].</div>Ppelletihttps://wiki.haskell.org/index.php?title=Template:Main/News&diff=61262Template:Main/News2016-11-02T07:38:05Z<p>Ppelleti: use locally hosted image instead of imgur</p>
<hr />
<div><div class="subtitle">Recent Package Updates [https://wiki.haskell.org/Hackage_statistics https://wiki.haskell.org/wikiupload/b/bf/MHvNV.png] [https://hackage.haskell.org/packages/recent.rss https://wiki.haskell.org/wikiupload/7/7c/Rss16.png]</div><br />
<br />
<div style="font-size:80%"><br />
See [https://hackage.haskell.org/packages/recent here]<br />
</div></div>Ppelletihttps://wiki.haskell.org/index.php?title=File:MHvNV.png&diff=61261File:MHvNV.png2016-11-02T07:36:24Z<p>Ppelleti: prevent wiki from inserting the actual image here</p>
<hr />
<div>This image was originally from <nowiki>https://i.imgur.com/mHvNV.png</nowiki> and is used on the home page, via the Main/News template. It seems to make sense to host this image locally, rather than using imgur.</div>Ppelletihttps://wiki.haskell.org/index.php?title=File:MHvNV.png&diff=61260File:MHvNV.png2016-11-02T07:34:21Z<p>Ppelleti: This image was originally from https://i.imgur.com/mHvNV.png and is used on the home page, via the Main/News template. It seems to make sense to host this image locally, rather than using imgur.</p>
<hr />
<div>This image was originally from https://i.imgur.com/mHvNV.png and is used on the home page, via the Main/News template. It seems to make sense to host this image locally, rather than using imgur.</div>Ppelletihttps://wiki.haskell.org/index.php?title=Template:Main/Community&diff=61259Template:Main/Community2016-11-02T06:56:01Z<p>Ppelleti: avoid mixed content warning for Rss16.png, and update other links to https as well</p>
<hr />
<div><div class="subtitle">Join the Community</div><br />
<br />
* Haskell on [https://www.reddit.com/r/haskell/ reddit], [https://stackoverflow.com/questions/tagged?tagnames=haskell Stack Overflow], [https://plus.google.com/communities/104818126031270146189 G+]<br />
* [[Mailing lists]], [[IRC channel|IRC channels]]<br />
* [[:Category:Haskell|Wiki]] ([[HaskellWiki:Contributing|how to contribute]])<br />
* [[Haskell Communities and Activities Report|Communities and Activities Reports]]<br />
* Haskell in [[Haskell in industry|industry]], [[Haskell in research|research]] and [[Haskell in education|education]].<br />
* [https://planet.haskell.org/ Planet Haskell] [https://planet.haskell.org/rss20.xml https://wiki.haskell.org/wikiupload/7/7c/Rss16.png], [https://themonadreader.wordpress.com/ The Monad.Reader]<br />
* Local [[user groups]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Template:Main/News&diff=61258Template:Main/News2016-11-02T06:50:50Z<p>Ppelleti: didn't get the image URL for Rss16.png right last time</p>
<hr />
<div><div class="subtitle">Recent Package Updates [https://wiki.haskell.org/Hackage_statistics https://i.imgur.com/mHvNV.png] [https://hackage.haskell.org/packages/recent.rss https://wiki.haskell.org/wikiupload/7/7c/Rss16.png]</div><br />
<br />
<div style="font-size:80%"><br />
See [https://hackage.haskell.org/packages/recent here]<br />
</div></div>Ppelletihttps://wiki.haskell.org/index.php?title=Template:Main/News&diff=61257Template:Main/News2016-11-02T06:46:45Z<p>Ppelleti: update URLs to use https; this avoids a mixed content warning</p>
<hr />
<div><div class="subtitle">Recent Package Updates [https://wiki.haskell.org/Hackage_statistics https://i.imgur.com/mHvNV.png] [https://hackage.haskell.org/packages/recent.rss https://haskell.org/wikiupload/7/7c/Rss16.png]</div><br />
<br />
<div style="font-size:80%"><br />
See [https://hackage.haskell.org/packages/recent here]<br />
</div></div>Ppelletihttps://wiki.haskell.org/index.php?title=Darcs&diff=61256Darcs2016-11-02T05:49:52Z<p>Ppelleti: /* External links */ patch-tag.com seems to no longer be operational</p>
<hr />
<div>'''darcs''' is a peer-to-peer revision control system, written in Haskell. It is the standard RCS of the Haskell community.<br />
<br />
== Understanding darcs ==<br />
<br />
You can think of a darcs repository as containing these things:<br />
<br />
* '''Patches''': a patch is a collection of changes that forms the unit of synchronisation with other repositories<br />
* Unrecorded '''changes''' to known files and directories<br />
* '''Unmanaged items''' (files and directories)<br />
* '''Boring items''': anything with a name matched in <tt>_darcs/prefs/boring</tt><br />
* The '''unrevert cache''' of changes<br />
<br />
Note that some projects are keen on making sure all derivative items are "boring" rather than merely unknown items that will show up with <tt>darcs wh -l</tt>. Other projects less so.<br />
<br />
== Operations ==<br />
<br />
=== Unmanaged items ===<br />
<br />
*<tt>darcs whatsnew -l</tt>: show changes to managed files, and unmanaged items<br />
<br />
*'''creating a item''': add item to the unmanaged items.<br />
<br />
*<tt>darcs add</tt>: convert the unmanaged item into a change to create the item and its contents<br />
<br />
*<tt>darcs remove</tt>: add a change which empties the item and deletes it, but keep it as an unmanaged item.<br />
<br />
=== Changes ===<br />
<br />
*<tt>darcs whatsnew</tt>: show unrecorded changes<br />
<br />
*'''removing a managed item''': add a change to remove the item<br />
<br />
*'''editing a managed file''': add a change for the edit<br />
<br />
*<tt>darcs mv</tt>: add a change to move an item<br />
<br />
*<tt>darcs replace</tt>: add a change to replace text in a file<br />
<br />
*<tt>darcs record</tt>: record changes to add a patch<br />
<br />
*<tt>darcs unrecord</tt>: remove a patch by turning back it into unrecorded changes<br />
<br />
*<tt>darcs amend-record</tt>: replace a patch with one with added changes<br />
<br />
*<tt>darcs revert</tt>: remove changes and put them in the unrevert cache. ''Warning: you will lose the previous contents of the unrevert cache.''<br />
<br />
*<tt>darcs unrevert</tt>: take changes out of the unrevert cache and add them to the unrecorded changes.<br />
<br />
=== Patches ===<br />
<br />
*<tt>darcs changes</tt>: show patches<br />
<br />
*<tt>darcs send --output=''FILE''</tt>: make an email bundle from patches<br />
<br />
*<tt>darcs send --to=''ADDRESS''</tt>: send an email bundle from patches<br />
<br />
*<tt>darcs pull</tt>: add patches from another repository<br />
<br />
*<tt>darcs push</tt>: add patches from this repository to another repository<br />
<br />
*<tt>darcs apply</tt>: add patches from an email bundle<br />
<br />
*<tt>darcs rollback</tt>: add a patch that is the inverse of an existing patch<br />
<br />
*<tt>darcs obliterate</tt>: remove a patch. ''Warning: if the patch doesn't exist elsewhere, you will lose that work.''<br />
<br />
*<tt>darcs tag</tt>: add a tag for the current set of patches<br />
<br />
=== Repositories ===<br />
<br />
*<tt>darcs initialize</tt>: create a new empty repository<br />
<br />
*<tt>darcs get</tt>: create a new empty repository and add patches from another repository<br />
<br />
== External links ==<br />
<br />
* [http://darcs.net/ darcs]<br />
* [http://hub.darcs.net darcsden/darcs hub] free darcs repository hosting<br />
* [http://en.wikibooks.org/wiki/Understanding_darcs Understanding darcs] - an illustrated wikibook about darcs and patch theory<br />
* [http://blog.interlinked.org/tutorials/darcs.html Darcs, Taking version control to the next level], a tutorial<br />
* [http://mark.stosberg.com/blog/2005/01/benefits-from-a-real-world-switch-from-cvs-to-darcs.html Benefits from a real world switch from CVS to darcs]<br />
* Implementation details of <code>darcs</code> show motivating examples for [[generalised algebraic datatype]]s. The motivations are described in David Roundy's slides [http://darcs.net/fosdem_talk/talk.pdf Implementing the darcs patch formalism and verifying it] (see p. 11, 13--14.). The talk mentions also the notions of [[phantom type]], and [[existential type]], and [[type witness]] (see p. 15).<br />
* See [http://web.archive.org/web/20070409170354/http://darcs.net/DarcsWiki/Talks also other talks] on <code>darcs</code>. One of them ([cufp.galois.com/2005/slides/DavidRoundy.pdf The Myth and Reality of using Haskell in the ‘Real World’]) discusses a more general topic: usefulness of Haskell (in real life) and in general, the power of (lazy) functional programming.<br />
* [http://wiki.darcs.net/ConfictMiseryAnalysis Conflict bug] -(a problem in Darcs-1)<br />
* <s>Another free darcs hosting (for open source projects) at patch-tag.com</s><br />
<br />
[[Category:Tools]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=Android&diff=61120Android2016-09-17T06:02:39Z<p>Ppelleti: /* Related */ sseefried/debian-stable-ghc-android does not exist</p>
<hr />
<div>{{Stub}}<br />
<br />
== Introduction == <br />
<br />
Android is an operating system for mobile devices, based on Linux; software development is mainly done in Java. See the [http://en.wikipedia.org/wiki/Android_(operating_system) Wikipedia article] for more information.<br />
<br />
<br />
== How to develop Android software in Haskell ==<br />
<br />
There are two main approaches to writing Android applications. You can either use<br />
the Java Native Interface ([http://en.wikipedia.org/wiki/Java_Native_Interface JNI])<br />
or the Native Development Kit ([https://developer.android.com/tools/sdk/ndk/index.html NDK]).<br />
<br />
If you'd like to go down the path of using the JNI there is a Haskell binding library [https://github.com/neurocyte/foreign-jni foreign-jni]; here is a demonstration of its use: [https://github.com/neurocyte/android-haskell-activity android-haskell-activity].<br />
An extension on the android-haskell-activity which includes a full cross platform build script and iOS support can be found here [https://github.com/EDeijl/CPHConsoleApp CPHConsoleApp].<br />
<br />
You can also create applications using the NDK. See the [https://github.com/ajhc/demo-android-ndk NativeActivity demo application] using the [http://ajhc.metasepi.org/ Ajhc Haskell compiler] for example.<br />
<br />
There has also been some success in compiling GHC as a cross compiler. See below.<br />
<br />
== Discussions ==<br />
<br />
* StackOverflow: [http://stackoverflow.com/questions/5151858/running-a-haskell-program-on-the-android-os Running a Haskell program on the Android OS]<br />
* Reddit: [http://www.reddit.com/r/haskell/comments/ful84/haskell_on_android/ Haskell on Android], [http://www.reddit.com/r/haskell_proposals/comments/fdz3y/haskell_bindings_for_android_ndk_apis/ Haskell bindings for Android NDK APIs] and [http://www.reddit.com/r/haskell_proposals/comments/7ihso/an_arm_port_of_ghc_that_works_so_we_can_program/ An ARM port of GHC that works (so we can program the iPhone or Android)]<br />
* Google+ [https://plus.google.com/101555949501667191720/posts/JaFk1HS5oR7 So who else is interested in getting Haskell running on Android?]<br />
<br />
<br />
== Related ==<br />
<br />
* [http://keera.co.uk/blog/category/haskell-2/ The blog of Keera Studios], a company that develops games in Haskell for Android<br />
* [http://hackage.haskell.org/trac/ghc/wiki/Building/CrossCompiling Cross-compiling GHC]<br />
* [https://github.com/neurocyte/ghc-android ghc-android]; a build script for building ghc cross compilers targeting Android.<br />
* [https://github.com/sseefried/docker-build-ghc-android docker-build-ghc-android]; a [https://www.docker.com/ Docker]file to build a GHC 7.8.3 cross compiler targeting Android on Debian Wheezy. Based heavily on [https://github.com/neurocyte/ghc-android ghc-android]. You can also just <code>docker pull [https://hub.docker.com/r/sseefried/debian-wheezy-ghc-android/ sseefried/debian-wheezy-ghc-android]</code> from the Docker Hub.<br />
* [https://github.com/conscell/hugs-android hugs-android]; a port of HUGS Haskell interpreter to Android.<br />
* [[ARM]]<br />
* [https://ghcarm.wordpress.com/ GHC on ARM]<br />
* [[iPhone]]<br />
<br />
<br />
[[Category:OS]]<br />
[[Category:Platforms]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=OpenWRT&diff=60990OpenWRT2016-08-09T16:07:00Z<p>Ppelleti: gmane has gone away</p>
<hr />
<div>This page attempts to explain various strategies for getting Haskell programs to run on [https://openwrt.org/ OpenWRT]. Since (AFAIK?) no attempt has been made to integrate ghc into [https://wiki.openwrt.org/doc/howto/build OpenWRT's buildroot], the strategies here are pretty much synonymous with [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling cross-compiling] and static linking Haskell programs in general, and are not specific to OpenWRT.<br />
<br />
== Cross-compiling for MIPS ==<br />
<br />
[https://github.com/wereHamster/onion-omega wereHamster has a github repository] of Dockerfiles for building a GHC cross-compiler for the [https://onion.io/omega Onion Omega].<br />
<br />
== Cross-compiling for x86_64 ==<br />
<br />
(Apologies for the first-person nature of the text; I originally wrote it as a blog post. Please feel free to edit it to be more third-person and wiki-appropriate.)<br />
<br />
I'd like to be able to run Haskell programs on my OpenWRT box.<br />
Since my OpenWRT box has an x86_64 processor, it could almost run the<br />
same binaries that my desktop Linux machine does. However, the reason<br />
it can't is because it uses a different C library. Desktop Linux<br />
(specifically Ubuntu in my case) uses glibc. OpenWRT used uclibc in<br />
past versions, and uses [http://www.musl-libc.org/ musl] on trunk. Since binaries are<br />
normally linked dynamically (and in the case of glibc, they pretty<br />
much have to be), the target machine needs to have the same C library<br />
that the executable was built with.<br />
<br />
One approach would be to dynamically link against the C library that<br />
OpenWRT uses. However, an even more robust approach is to link the<br />
executable statically. Then it can run on ''any'' x86_64 Linux machine,<br />
regardless of what libraries it has installed.<br />
<br />
Unfortunately, glibc doesn't really work correctly with fully static<br />
linking. Therefore, another C library needs to be used. The best<br />
choice seems to be musl. Coincidentally, musl is also the C library<br />
used by OpenWRT trunk, but since we're going to link statically, it<br />
wouldn't have to be.<br />
<br />
So, how do we compile and link Haskell programs against musl? One<br />
approach is to use [https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html a musl version of ghc]. Unfortunately, that<br />
approach requires a full musl-based Linux system to run on. The<br />
author of that post recommends a musl-based Gentoo distribution, but<br />
that seemed kind of icky to me. I almost could use the OpenWRT box as<br />
the musl-based build system, but that would require a working gcc on<br />
the OpenWRT box. Currently, on OpenWRT trunk,<br />
[https://github.com/openwrt/packages/issues/2244 the gcc package is broken].<br />
<br />
What I really want is a cross-compiler, which will run on my<br />
glibc-based Ubuntu box, but will build executables that use<br />
statically-linked musl. That, in turn, requires having a<br />
cross-compiling toolchain (gcc, binutils, etc.) before building the<br />
ghc cross-compiler. There are several ways to satisfy this<br />
requirement, but after a<br />
[https://mail.haskell.org/pipermail/haskell-cafe/2016-April/123610.html recommendation on the haskell-cafe mailing list], I<br />
decided to give [http://crosstool-ng.org/ Crosstool-NG] a try.<br />
<br />
I discovered that, in addition to the packages already installed on my<br />
system, I needed to install these packages in order to get<br />
Crosstool-NG to work:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ sudo apt-get install gperf bison texinfo help2man python-dev<br />
</pre><br />
<br />
To avoid confusion, keep in mind that there are four directories relevant to Crosstool-NG:<br />
<br />
# The directory you build Crosstool-NG in. In this example, it is <code>~/src/crosstool-ng</code><br />
# The directory you install Crosstool-NG in. In this example, it is <code>/usr/local</code><br />
# The directory you build the toolchain in. In this example, it is <code>~/crosstool-ng</code><br />
# The directory you install the toolchain in. In this example, it is <code>~/x-tools/x86_64-unknown-linux-musl</code> (which I did not have to specify explicitly, because it is the default)<br />
<br />
(Once you've installed Crosstool-NG, you can delete the directory in (1), and once you've installed the toolchain, you can delete the directory in (3), to save space. The end result you care about is in directory (4).)<br />
<br />
So, I got started with Crosstool-NG:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ cd crosstool-ng/<br />
ppelletier@patrick64:~/src/crosstool-ng$ ./configure --prefix=/usr/local<br />
ppelletier@patrick64:~/src/crosstool-ng$ make<br />
ppelletier@patrick64:~/src/crosstool-ng$ sudo make install<br />
ppelletier@patrick64:~/src/crosstool-ng$ mkdir ~/crosstool-ng<br />
ppelletier@patrick64:~/src/crosstool-ng$ cd ~/crosstool-ng<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng x86_64-unknown-linux-gnu<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng menuconfig<br />
</pre><br />
<br />
In the menuconfig, I selected '''C-library > C library > musl''', and<br />
it's also a good idea to de-select<br />
'''Paths and misc options > Render the toolchain read-only''',<br />
because I'm going to install the GHC cross-compiler in the same<br />
directory tree, so the directories need to be writable.<br />
<br />
Then, I was able to do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng build<br />
</pre><br />
<br />
And a little over an hour later, I could do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools$ export PATH="${PATH}:${HOME}/x-tools/x86_64-unknown-linux-musl/bin"<br />
ppelletier@patrick64:~/x-tools$ x86_64-unknown-linux-musl-gcc --version<br />
x86_64-unknown-linux-musl-gcc (crosstool-NG crosstool-ng-1.22.0) 5.2.0<br />
Copyright (C) 2015 Free Software Foundation, Inc.<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
</pre><br />
<br />
Next, I read [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling the instructions for cross-compiling ghc], and then I<br />
did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ cd ghc-7.10.3/<br />
</pre><br />
<br />
And then I attempted to build GHC. I ran into some issues along the<br />
way, so I'm going to present the fixes to those issues now, rather<br />
than reconstructing the exact order in which I did things.<br />
<br />
The main issue is that GHC needs ncurses on the target. I'm not sure<br />
why, but it does. So, I had to go and cross-compile ncurses:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ ./configure --host=x86_64-unknown-linux-musl --prefix=${HOME}/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ncurses-6.0$ make<br />
</pre><br />
<br />
Well, that ended up failing with:<br />
<br />
<pre><br />
x86_64-unknown-linux-musl-gcc -DHAVE_CONFIG_H -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -c ../ncurses/lib_gen.c -o ../objects/lib_gen.o<br />
In file included from ./curses.priv.h:325:0,<br />
from ../ncurses/lib_gen.c:19:<br />
_20591.c:843:15: error: expected ')' before 'int'<br />
../include/curses.h:1631:56: note: in definition of macro 'mouse_trafo'<br />
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)<br />
^<br />
make[1]: *** [../objects/lib_gen.o] Error 1<br />
make[1]: Leaving directory `/home/ppelletier/src/ncurses-6.0/ncurses'<br />
make: *** [all] Error 2<br />
</pre><br />
<br />
I found the answer in [https://github.com/wereHamster/onion-omega/blob/master/ghc/Dockerfile wereHamster's Dockerfile]. In<br />
<code>ncurses/base/MKlib_gen.sh</code>, line 65 needs to be changed from:<br />
<br />
<pre><br />
preprocessor="$1 -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
to:<br />
<br />
<pre><br />
preprocessor="$1 -P -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
Okay, now the <code>make</code> succeeds, and after <code>make</code>, I do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ make install<br />
</pre><br />
<br />
However, this is not enough. I thought that by installing it under<br />
the cross toolchain's prefix, gcc would automatically pick up the<br />
ncurses includes. But it didn't. So, I need to specify<br />
<code>--with-curses-includes</code> and <code>--with-curses-libraries</code> to ghc's<br />
<code>configure</code>. Unfortunately, there doesn't seem to be a single value<br />
that works for <code>--with-curses-includes</code>, and it doesn't seem to be<br />
possible to specify more than one value for <code>--with-curses-includes</code>.<br />
<br />
If I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include</code>,<br />
then the build is unable to find <code>ncurses.h</code>. However, if I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses</code>,<br />
then <code>ncurses.h</code> includes <code>ncurses/ncurses_dll.h</code>, which is not<br />
found. My really ugly solution was:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools/x86_64-unknown-linux-musl/include/ncurses$ ln -s . ncurses<br />
</pre><br />
<br />
Now we're ready to actually build ghc successfully. In the<br />
<code>~/src/ghc-7.10.3/mk</code> directory, I copied <code>build.mk.sample</code> to<br />
<code>build.mk</code>, and then uncommented <code>BuildFlavour = quick-cross</code>. Next<br />
I did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ghc-7.10.3$ ./configure --target=x86_64-unknown-linux-musl --with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses --with-curses-libraries=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/lib --prefix=/home/ppelletier/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make install<br />
</pre><br />
<br />
It turns out that this toolchain still links dynamically by default,<br />
so I have to specify <code>-static -optl-static</code> when compiling Haskell<br />
programs. For example:<br />
<br />
<pre><br />
ppelletier@patrick64:~/programming/haskell$ x86_64-unknown-linux-musl-ghc -O -static -optl-static contact.hs<br />
[1 of 1] Compiling Main ( contact.hs, contact.o )<br />
Linking contact ...<br />
ppelletier@patrick64:~/programming/haskell$ file contact<br />
contact: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped<br />
ppelletier@patrick64:~/programming/haskell$ ldd contact<br />
not a dynamic executable<br />
</pre><br />
<br />
The <code>contact</code> executable can now be run on either my Ubuntu box or my<br />
OpenWRT box.<br />
<br />
However, in order to build nontrivial programs, I need cabal. The [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling GHC cross-compiling page] recommends:<br />
<br />
<pre><br />
cabal --with-ghc=<cross-ghc> --with-ld=<ld> ...<br />
</pre><br />
<br />
So I expanded this approach to:<br />
<br />
<pre><br />
alias mcabal="cabal --with-ghc=x86_64-unknown-linux-musl-ghc --with-ld=x86_64-unknown-linux-musl-ld --with-gcc=x86_64-unknown-linux-musl-gcc --with-ghc-pkg=x86_64-unknown-linux-musl-ghc-pkg"<br />
</pre><br />
<br />
I'm able to install some packages with mcabal. (For example, <code>mcabal install hourglass</code>.)<br />
<br />
But with cryptonite, I get:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/lifx/lifx-programs$ mcabal install --flags=-integer-gmp cryptonite<br />
Resolving dependencies...<br />
Configuring memory-0.12...<br />
Building memory-0.12...<br />
Preprocessing library memory-0.12...<br />
running dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make failed (exit code 127)<br />
command was: dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make >dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix.hs<br />
Failed to install memory-0.12<br />
cabal: Error: some packages failed to install:<br />
cryptonite-0.15 depends on memory-0.12 which failed to install.<br />
memory-0.12 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
I haven't been able to figure out exactly what's going on there.<br />
<br />
Or, <code>mcabal install aeson</code> fails with:<br />
<br />
<pre><br />
Building aeson-0.11.1.4...<br />
Preprocessing library aeson-0.11.1.4...<br />
ghc: Data/Aeson/TH.hs:9:14-28: Template Haskell requires GHC with interpreter support<br />
Perhaps you are using a stage-1 compiler?<br />
Usage: For basic information, try the `--help' option.<br />
Failed to install aeson-0.11.1.4<br />
cabal: Error: some packages failed to install:<br />
aeson-0.11.1.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
== Native GHC for musl ==<br />
<br />
Given the issues with cabal and Template Haskell when cross-compiling, the best solution (for x86_64, at least) may be a native GHC compiler which is linked against musl.<br />
<br />
[https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html Marios Titas has a haskell-cafe post] and a [https://github.com/redneb/ghc-alt-libc/ github repository] about a musl-native ghc toolchain.<br />
<br />
If you prefer Docker over chroot, there is [https://hub.docker.com/r/nilcons/ghc-musl/ a Docker image] based on [https://alpinelinux.org/about/ Alpine Linux], and the corresponding Dockerfile is [https://github.com/nilcons/ghc-musl on github].<br />
<br />
Here is an example of using that Docker image to build a static executable with cabal:<br />
<br />
<pre><br />
ppelletier@patrick64:~$ sudo docker run -it nilcons/ghc-musl:cabal sh<br />
Unable to find image 'nilcons/ghc-musl:cabal' locally<br />
cabal: Pulling from nilcons/ghc-musl<br />
c862d82a67a2: Pull complete<br />
00b183080618: Pull complete<br />
7193868286e6: Pull complete<br />
a3ed95caeb02: Pull complete<br />
bbfc077cc684: Pull complete<br />
Digest: sha256:27657bba49ed54b57d10c964ff59fc275d47d26e3e3a8e5991c61edc9f5f40b2<br />
Status: Downloaded newer image for nilcons/ghc-musl:cabal<br />
/ # cabal update<br />
Downloading the latest package list from hackage.haskell.org<br />
/ # cabal install --ghc-option=-optl-static hello<br />
Resolving dependencies...<br />
Configuring hello-1.0.0.2...<br />
Building hello-1.0.0.2...<br />
Installed hello-1.0.0.2<br />
/ # which hello<br />
/root/.cabal/bin/hello<br />
/ # hello<br />
Hello, World!<br />
/ # file /root/.cabal/bin/hello<br />
/root/.cabal/bin/hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped<br />
/ # ldd /root/.cabal/bin/hello<br />
ldd: /root/.cabal/bin/hello: Not a valid dynamic program<br />
</pre><br />
<br />
[[Category:OS]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=OpenWRT&diff=60688OpenWRT2016-04-19T03:22:48Z<p>Ppelleti: example of static linking with cabal, using ghc-musl Docker image</p>
<hr />
<div>This page attempts to explain various strategies for getting Haskell programs to run on [https://openwrt.org/ OpenWRT]. Since (AFAIK?) no attempt has been made to integrate ghc into [https://wiki.openwrt.org/doc/howto/build OpenWRT's buildroot], the strategies here are pretty much synonymous with [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling cross-compiling] and static linking Haskell programs in general, and are not specific to OpenWRT.<br />
<br />
== Cross-compiling for MIPS ==<br />
<br />
[https://github.com/wereHamster/onion-omega wereHamster has a github repository] of Dockerfiles for building a GHC cross-compiler for the [https://onion.io/omega Onion Omega].<br />
<br />
== Cross-compiling for x86_64 ==<br />
<br />
(Apologies for the first-person nature of the text; I originally wrote it as a blog post. Please feel free to edit it to be more third-person and wiki-appropriate.)<br />
<br />
I'd like to be able to run Haskell programs on my OpenWRT box.<br />
Since my OpenWRT box has an x86_64 processor, it could almost run the<br />
same binaries that my desktop Linux machine does. However, the reason<br />
it can't is because it uses a different C library. Desktop Linux<br />
(specifically Ubuntu in my case) uses glibc. OpenWRT used uclibc in<br />
past versions, and uses [http://www.musl-libc.org/ musl] on trunk. Since binaries are<br />
normally linked dynamically (and in the case of glibc, they pretty<br />
much have to be), the target machine needs to have the same C library<br />
that the executable was built with.<br />
<br />
One approach would be to dynamically link against the C library that<br />
OpenWRT uses. However, an even more robust approach is to link the<br />
executable statically. Then it can run on ''any'' x86_64 Linux machine,<br />
regardless of what libraries it has installed.<br />
<br />
Unfortunately, glibc doesn't really work correctly with fully static<br />
linking. Therefore, another C library needs to be used. The best<br />
choice seems to be musl. Coincidentally, musl is also the C library<br />
used by OpenWRT trunk, but since we're going to link statically, it<br />
wouldn't have to be.<br />
<br />
So, how do we compile and link Haskell programs against musl? One<br />
approach is to use [https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html a musl version of ghc]. Unfortunately, that<br />
approach requires a full musl-based Linux system to run on. The<br />
author of that post recommends a musl-based Gentoo distribution, but<br />
that seemed kind of icky to me. I almost could use the OpenWRT box as<br />
the musl-based build system, but that would require a working gcc on<br />
the OpenWRT box. Currently, on OpenWRT trunk,<br />
[https://github.com/openwrt/packages/issues/2244 the gcc package is broken].<br />
<br />
What I really want is a cross-compiler, which will run on my<br />
glibc-based Ubuntu box, but will build executables that use<br />
statically-linked musl. That, in turn, requires having a<br />
cross-compiling toolchain (gcc, binutils, etc.) before building the<br />
ghc cross-compiler. There are several ways to satisfy this<br />
requirement, but after a<br />
[http://mid.gmane.org/CAPabhsKjsMh667uKvBowr0S6OCbK6rZJgaoVPMrfd9_VOAdRMQ@mail.gmail.com recommendation on the haskell-cafe mailing list], I<br />
decided to give [http://crosstool-ng.org/ Crosstool-NG] a try.<br />
<br />
I discovered that, in addition to the packages already installed on my<br />
system, I needed to install these packages in order to get<br />
Crosstool-NG to work:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ sudo apt-get install gperf bison texinfo help2man python-dev<br />
</pre><br />
<br />
To avoid confusion, keep in mind that there are four directories relevant to Crosstool-NG:<br />
<br />
# The directory you build Crosstool-NG in. In this example, it is <code>~/src/crosstool-ng</code><br />
# The directory you install Crosstool-NG in. In this example, it is <code>/usr/local</code><br />
# The directory you build the toolchain in. In this example, it is <code>~/crosstool-ng</code><br />
# The directory you install the toolchain in. In this example, it is <code>~/x-tools/x86_64-unknown-linux-musl</code> (which I did not have to specify explicitly, because it is the default)<br />
<br />
(Once you've installed Crosstool-NG, you can delete the directory in (1), and once you've installed the toolchain, you can delete the directory in (3), to save space. The end result you care about is in directory (4).)<br />
<br />
So, I got started with Crosstool-NG:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ cd crosstool-ng/<br />
ppelletier@patrick64:~/src/crosstool-ng$ ./configure --prefix=/usr/local<br />
ppelletier@patrick64:~/src/crosstool-ng$ make<br />
ppelletier@patrick64:~/src/crosstool-ng$ sudo make install<br />
ppelletier@patrick64:~/src/crosstool-ng$ mkdir ~/crosstool-ng<br />
ppelletier@patrick64:~/src/crosstool-ng$ cd ~/crosstool-ng<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng x86_64-unknown-linux-gnu<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng menuconfig<br />
</pre><br />
<br />
In the menuconfig, I selected '''C-library > C library > musl''', and<br />
it's also a good idea to de-select<br />
'''Paths and misc options > Render the toolchain read-only''',<br />
because I'm going to install the GHC cross-compiler in the same<br />
directory tree, so the directories need to be writable.<br />
<br />
Then, I was able to do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng build<br />
</pre><br />
<br />
And a little over an hour later, I could do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools$ export PATH="${PATH}:${HOME}/x-tools/x86_64-unknown-linux-musl/bin"<br />
ppelletier@patrick64:~/x-tools$ x86_64-unknown-linux-musl-gcc --version<br />
x86_64-unknown-linux-musl-gcc (crosstool-NG crosstool-ng-1.22.0) 5.2.0<br />
Copyright (C) 2015 Free Software Foundation, Inc.<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
</pre><br />
<br />
Next, I read [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling the instructions for cross-compiling ghc], and then I<br />
did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ cd ghc-7.10.3/<br />
</pre><br />
<br />
And then I attempted to build GHC. I ran into some issues along the<br />
way, so I'm going to present the fixes to those issues now, rather<br />
than reconstructing the exact order in which I did things.<br />
<br />
The main issue is that GHC needs ncurses on the target. I'm not sure<br />
why, but it does. So, I had to go and cross-compile ncurses:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ ./configure --host=x86_64-unknown-linux-musl --prefix=${HOME}/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ncurses-6.0$ make<br />
</pre><br />
<br />
Well, that ended up failing with:<br />
<br />
<pre><br />
x86_64-unknown-linux-musl-gcc -DHAVE_CONFIG_H -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -c ../ncurses/lib_gen.c -o ../objects/lib_gen.o<br />
In file included from ./curses.priv.h:325:0,<br />
from ../ncurses/lib_gen.c:19:<br />
_20591.c:843:15: error: expected ')' before 'int'<br />
../include/curses.h:1631:56: note: in definition of macro 'mouse_trafo'<br />
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)<br />
^<br />
make[1]: *** [../objects/lib_gen.o] Error 1<br />
make[1]: Leaving directory `/home/ppelletier/src/ncurses-6.0/ncurses'<br />
make: *** [all] Error 2<br />
</pre><br />
<br />
I found the answer in [https://github.com/wereHamster/onion-omega/blob/master/ghc/Dockerfile wereHamster's Dockerfile]. In<br />
<code>ncurses/base/MKlib_gen.sh</code>, line 65 needs to be changed from:<br />
<br />
<pre><br />
preprocessor="$1 -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
to:<br />
<br />
<pre><br />
preprocessor="$1 -P -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
Okay, now the <code>make</code> succeeds, and after <code>make</code>, I do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ make install<br />
</pre><br />
<br />
However, this is not enough. I thought that by installing it under<br />
the cross toolchain's prefix, gcc would automatically pick up the<br />
ncurses includes. But it didn't. So, I need to specify<br />
<code>--with-curses-includes</code> and <code>--with-curses-libraries</code> to ghc's<br />
<code>configure</code>. Unfortunately, there doesn't seem to be a single value<br />
that works for <code>--with-curses-includes</code>, and it doesn't seem to be<br />
possible to specify more than one value for <code>--with-curses-includes</code>.<br />
<br />
If I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include</code>,<br />
then the build is unable to find <code>ncurses.h</code>. However, if I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses</code>,<br />
then <code>ncurses.h</code> includes <code>ncurses/ncurses_dll.h</code>, which is not<br />
found. My really ugly solution was:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools/x86_64-unknown-linux-musl/include/ncurses$ ln -s . ncurses<br />
</pre><br />
<br />
Now we're ready to actually build ghc successfully. In the<br />
<code>~/src/ghc-7.10.3/mk</code> directory, I copied <code>build.mk.sample</code> to<br />
<code>build.mk</code>, and then uncommented <code>BuildFlavour = quick-cross</code>. Next<br />
I did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ghc-7.10.3$ ./configure --target=x86_64-unknown-linux-musl --with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses --with-curses-libraries=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/lib --prefix=/home/ppelletier/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make install<br />
</pre><br />
<br />
It turns out that this toolchain still links dynamically by default,<br />
so I have to specify <code>-static -optl-static</code> when compiling Haskell<br />
programs. For example:<br />
<br />
<pre><br />
ppelletier@patrick64:~/programming/haskell$ x86_64-unknown-linux-musl-ghc -O -static -optl-static contact.hs<br />
[1 of 1] Compiling Main ( contact.hs, contact.o )<br />
Linking contact ...<br />
ppelletier@patrick64:~/programming/haskell$ file contact<br />
contact: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped<br />
ppelletier@patrick64:~/programming/haskell$ ldd contact<br />
not a dynamic executable<br />
</pre><br />
<br />
The <code>contact</code> executable can now be run on either my Ubuntu box or my<br />
OpenWRT box.<br />
<br />
However, in order to build nontrivial programs, I need cabal. The [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling GHC cross-compiling page] recommends:<br />
<br />
<pre><br />
cabal --with-ghc=<cross-ghc> --with-ld=<ld> ...<br />
</pre><br />
<br />
So I expanded this approach to:<br />
<br />
<pre><br />
alias mcabal="cabal --with-ghc=x86_64-unknown-linux-musl-ghc --with-ld=x86_64-unknown-linux-musl-ld --with-gcc=x86_64-unknown-linux-musl-gcc --with-ghc-pkg=x86_64-unknown-linux-musl-ghc-pkg"<br />
</pre><br />
<br />
I'm able to install some packages with mcabal. (For example, <code>mcabal install hourglass</code>.)<br />
<br />
But with cryptonite, I get:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/lifx/lifx-programs$ mcabal install --flags=-integer-gmp cryptonite<br />
Resolving dependencies...<br />
Configuring memory-0.12...<br />
Building memory-0.12...<br />
Preprocessing library memory-0.12...<br />
running dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make failed (exit code 127)<br />
command was: dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make >dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix.hs<br />
Failed to install memory-0.12<br />
cabal: Error: some packages failed to install:<br />
cryptonite-0.15 depends on memory-0.12 which failed to install.<br />
memory-0.12 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
I haven't been able to figure out exactly what's going on there.<br />
<br />
Or, <code>mcabal install aeson</code> fails with:<br />
<br />
<pre><br />
Building aeson-0.11.1.4...<br />
Preprocessing library aeson-0.11.1.4...<br />
ghc: Data/Aeson/TH.hs:9:14-28: Template Haskell requires GHC with interpreter support<br />
Perhaps you are using a stage-1 compiler?<br />
Usage: For basic information, try the `--help' option.<br />
Failed to install aeson-0.11.1.4<br />
cabal: Error: some packages failed to install:<br />
aeson-0.11.1.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
== Native GHC for musl ==<br />
<br />
Given the issues with cabal and Template Haskell when cross-compiling, the best solution (for x86_64, at least) may be a native GHC compiler which is linked against musl.<br />
<br />
[https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html Marios Titas has a haskell-cafe post] and a [https://github.com/redneb/ghc-alt-libc/ github repository] about a musl-native ghc toolchain.<br />
<br />
If you prefer Docker over chroot, there is [https://hub.docker.com/r/nilcons/ghc-musl/ a Docker image] based on [https://alpinelinux.org/about/ Alpine Linux], and the corresponding Dockerfile is [https://github.com/nilcons/ghc-musl on github].<br />
<br />
Here is an example of using that Docker image to build a static executable with cabal:<br />
<br />
<pre><br />
ppelletier@patrick64:~$ sudo docker run -it nilcons/ghc-musl:cabal sh<br />
Unable to find image 'nilcons/ghc-musl:cabal' locally<br />
cabal: Pulling from nilcons/ghc-musl<br />
c862d82a67a2: Pull complete<br />
00b183080618: Pull complete<br />
7193868286e6: Pull complete<br />
a3ed95caeb02: Pull complete<br />
bbfc077cc684: Pull complete<br />
Digest: sha256:27657bba49ed54b57d10c964ff59fc275d47d26e3e3a8e5991c61edc9f5f40b2<br />
Status: Downloaded newer image for nilcons/ghc-musl:cabal<br />
/ # cabal update<br />
Downloading the latest package list from hackage.haskell.org<br />
/ # cabal install --ghc-option=-optl-static hello<br />
Resolving dependencies...<br />
Configuring hello-1.0.0.2...<br />
Building hello-1.0.0.2...<br />
Installed hello-1.0.0.2<br />
/ # which hello<br />
/root/.cabal/bin/hello<br />
/ # hello<br />
Hello, World!<br />
/ # file /root/.cabal/bin/hello<br />
/root/.cabal/bin/hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped<br />
/ # ldd /root/.cabal/bin/hello<br />
ldd: /root/.cabal/bin/hello: Not a valid dynamic program<br />
</pre><br />
<br />
[[Category:OS]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=OpenWRT&diff=60687OpenWRT2016-04-19T02:39:00Z<p>Ppelleti: /* Cross-compiling for x86_64 */ explain crosstool-ng directories</p>
<hr />
<div>This page attempts to explain various strategies for getting Haskell programs to run on [https://openwrt.org/ OpenWRT]. Since (AFAIK?) no attempt has been made to integrate ghc into [https://wiki.openwrt.org/doc/howto/build OpenWRT's buildroot], the strategies here are pretty much synonymous with [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling cross-compiling] and static linking Haskell programs in general, and are not specific to OpenWRT.<br />
<br />
== Cross-compiling for MIPS ==<br />
<br />
[https://github.com/wereHamster/onion-omega wereHamster has a github repository] of Dockerfiles for building a GHC cross-compiler for the [https://onion.io/omega Onion Omega].<br />
<br />
== Cross-compiling for x86_64 ==<br />
<br />
(Apologies for the first-person nature of the text; I originally wrote it as a blog post. Please feel free to edit it to be more third-person and wiki-appropriate.)<br />
<br />
I'd like to be able to run Haskell programs on my OpenWRT box.<br />
Since my OpenWRT box has an x86_64 processor, it could almost run the<br />
same binaries that my desktop Linux machine does. However, the reason<br />
it can't is because it uses a different C library. Desktop Linux<br />
(specifically Ubuntu in my case) uses glibc. OpenWRT used uclibc in<br />
past versions, and uses [http://www.musl-libc.org/ musl] on trunk. Since binaries are<br />
normally linked dynamically (and in the case of glibc, they pretty<br />
much have to be), the target machine needs to have the same C library<br />
that the executable was built with.<br />
<br />
One approach would be to dynamically link against the C library that<br />
OpenWRT uses. However, an even more robust approach is to link the<br />
executable statically. Then it can run on ''any'' x86_64 Linux machine,<br />
regardless of what libraries it has installed.<br />
<br />
Unfortunately, glibc doesn't really work correctly with fully static<br />
linking. Therefore, another C library needs to be used. The best<br />
choice seems to be musl. Coincidentally, musl is also the C library<br />
used by OpenWRT trunk, but since we're going to link statically, it<br />
wouldn't have to be.<br />
<br />
So, how do we compile and link Haskell programs against musl? One<br />
approach is to use [https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html a musl version of ghc]. Unfortunately, that<br />
approach requires a full musl-based Linux system to run on. The<br />
author of that post recommends a musl-based Gentoo distribution, but<br />
that seemed kind of icky to me. I almost could use the OpenWRT box as<br />
the musl-based build system, but that would require a working gcc on<br />
the OpenWRT box. Currently, on OpenWRT trunk,<br />
[https://github.com/openwrt/packages/issues/2244 the gcc package is broken].<br />
<br />
What I really want is a cross-compiler, which will run on my<br />
glibc-based Ubuntu box, but will build executables that use<br />
statically-linked musl. That, in turn, requires having a<br />
cross-compiling toolchain (gcc, binutils, etc.) before building the<br />
ghc cross-compiler. There are several ways to satisfy this<br />
requirement, but after a<br />
[http://mid.gmane.org/CAPabhsKjsMh667uKvBowr0S6OCbK6rZJgaoVPMrfd9_VOAdRMQ@mail.gmail.com recommendation on the haskell-cafe mailing list], I<br />
decided to give [http://crosstool-ng.org/ Crosstool-NG] a try.<br />
<br />
I discovered that, in addition to the packages already installed on my<br />
system, I needed to install these packages in order to get<br />
Crosstool-NG to work:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ sudo apt-get install gperf bison texinfo help2man python-dev<br />
</pre><br />
<br />
To avoid confusion, keep in mind that there are four directories relevant to Crosstool-NG:<br />
<br />
# The directory you build Crosstool-NG in. In this example, it is <code>~/src/crosstool-ng</code><br />
# The directory you install Crosstool-NG in. In this example, it is <code>/usr/local</code><br />
# The directory you build the toolchain in. In this example, it is <code>~/crosstool-ng</code><br />
# The directory you install the toolchain in. In this example, it is <code>~/x-tools/x86_64-unknown-linux-musl</code> (which I did not have to specify explicitly, because it is the default)<br />
<br />
(Once you've installed Crosstool-NG, you can delete the directory in (1), and once you've installed the toolchain, you can delete the directory in (3), to save space. The end result you care about is in directory (4).)<br />
<br />
So, I got started with Crosstool-NG:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ cd crosstool-ng/<br />
ppelletier@patrick64:~/src/crosstool-ng$ ./configure --prefix=/usr/local<br />
ppelletier@patrick64:~/src/crosstool-ng$ make<br />
ppelletier@patrick64:~/src/crosstool-ng$ sudo make install<br />
ppelletier@patrick64:~/src/crosstool-ng$ mkdir ~/crosstool-ng<br />
ppelletier@patrick64:~/src/crosstool-ng$ cd ~/crosstool-ng<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng x86_64-unknown-linux-gnu<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng menuconfig<br />
</pre><br />
<br />
In the menuconfig, I selected '''C-library > C library > musl''', and<br />
it's also a good idea to de-select<br />
'''Paths and misc options > Render the toolchain read-only''',<br />
because I'm going to install the GHC cross-compiler in the same<br />
directory tree, so the directories need to be writable.<br />
<br />
Then, I was able to do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng build<br />
</pre><br />
<br />
And a little over an hour later, I could do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools$ export PATH="${PATH}:${HOME}/x-tools/x86_64-unknown-linux-musl/bin"<br />
ppelletier@patrick64:~/x-tools$ x86_64-unknown-linux-musl-gcc --version<br />
x86_64-unknown-linux-musl-gcc (crosstool-NG crosstool-ng-1.22.0) 5.2.0<br />
Copyright (C) 2015 Free Software Foundation, Inc.<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
</pre><br />
<br />
Next, I read [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling the instructions for cross-compiling ghc], and then I<br />
did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ cd ghc-7.10.3/<br />
</pre><br />
<br />
And then I attempted to build GHC. I ran into some issues along the<br />
way, so I'm going to present the fixes to those issues now, rather<br />
than reconstructing the exact order in which I did things.<br />
<br />
The main issue is that GHC needs ncurses on the target. I'm not sure<br />
why, but it does. So, I had to go and cross-compile ncurses:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ ./configure --host=x86_64-unknown-linux-musl --prefix=${HOME}/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ncurses-6.0$ make<br />
</pre><br />
<br />
Well, that ended up failing with:<br />
<br />
<pre><br />
x86_64-unknown-linux-musl-gcc -DHAVE_CONFIG_H -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -c ../ncurses/lib_gen.c -o ../objects/lib_gen.o<br />
In file included from ./curses.priv.h:325:0,<br />
from ../ncurses/lib_gen.c:19:<br />
_20591.c:843:15: error: expected ')' before 'int'<br />
../include/curses.h:1631:56: note: in definition of macro 'mouse_trafo'<br />
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)<br />
^<br />
make[1]: *** [../objects/lib_gen.o] Error 1<br />
make[1]: Leaving directory `/home/ppelletier/src/ncurses-6.0/ncurses'<br />
make: *** [all] Error 2<br />
</pre><br />
<br />
I found the answer in [https://github.com/wereHamster/onion-omega/blob/master/ghc/Dockerfile wereHamster's Dockerfile]. In<br />
<code>ncurses/base/MKlib_gen.sh</code>, line 65 needs to be changed from:<br />
<br />
<pre><br />
preprocessor="$1 -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
to:<br />
<br />
<pre><br />
preprocessor="$1 -P -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
Okay, now the <code>make</code> succeeds, and after <code>make</code>, I do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ make install<br />
</pre><br />
<br />
However, this is not enough. I thought that by installing it under<br />
the cross toolchain's prefix, gcc would automatically pick up the<br />
ncurses includes. But it didn't. So, I need to specify<br />
<code>--with-curses-includes</code> and <code>--with-curses-libraries</code> to ghc's<br />
<code>configure</code>. Unfortunately, there doesn't seem to be a single value<br />
that works for <code>--with-curses-includes</code>, and it doesn't seem to be<br />
possible to specify more than one value for <code>--with-curses-includes</code>.<br />
<br />
If I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include</code>,<br />
then the build is unable to find <code>ncurses.h</code>. However, if I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses</code>,<br />
then <code>ncurses.h</code> includes <code>ncurses/ncurses_dll.h</code>, which is not<br />
found. My really ugly solution was:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools/x86_64-unknown-linux-musl/include/ncurses$ ln -s . ncurses<br />
</pre><br />
<br />
Now we're ready to actually build ghc successfully. In the<br />
<code>~/src/ghc-7.10.3/mk</code> directory, I copied <code>build.mk.sample</code> to<br />
<code>build.mk</code>, and then uncommented <code>BuildFlavour = quick-cross</code>. Next<br />
I did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ghc-7.10.3$ ./configure --target=x86_64-unknown-linux-musl --with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses --with-curses-libraries=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/lib --prefix=/home/ppelletier/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make install<br />
</pre><br />
<br />
It turns out that this toolchain still links dynamically by default,<br />
so I have to specify <code>-static -optl-static</code> when compiling Haskell<br />
programs. For example:<br />
<br />
<pre><br />
ppelletier@patrick64:~/programming/haskell$ x86_64-unknown-linux-musl-ghc -O -static -optl-static contact.hs<br />
[1 of 1] Compiling Main ( contact.hs, contact.o )<br />
Linking contact ...<br />
ppelletier@patrick64:~/programming/haskell$ file contact<br />
contact: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped<br />
ppelletier@patrick64:~/programming/haskell$ ldd contact<br />
not a dynamic executable<br />
</pre><br />
<br />
The <code>contact</code> executable can now be run on either my Ubuntu box or my<br />
OpenWRT box.<br />
<br />
However, in order to build nontrivial programs, I need cabal. The [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling GHC cross-compiling page] recommends:<br />
<br />
<pre><br />
cabal --with-ghc=<cross-ghc> --with-ld=<ld> ...<br />
</pre><br />
<br />
So I expanded this approach to:<br />
<br />
<pre><br />
alias mcabal="cabal --with-ghc=x86_64-unknown-linux-musl-ghc --with-ld=x86_64-unknown-linux-musl-ld --with-gcc=x86_64-unknown-linux-musl-gcc --with-ghc-pkg=x86_64-unknown-linux-musl-ghc-pkg --disable-executable-dynamic"<br />
</pre><br />
<br />
I'm able to install some packages with mcabal. (For example, <code>mcabal install hourglass</code>.)<br />
<br />
But with cryptonite, I get:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/lifx/lifx-programs$ mcabal install --flags=-integer-gmp cryptonite<br />
Resolving dependencies...<br />
Configuring memory-0.12...<br />
Building memory-0.12...<br />
Preprocessing library memory-0.12...<br />
running dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make failed (exit code 127)<br />
command was: dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make >dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix.hs<br />
Failed to install memory-0.12<br />
cabal: Error: some packages failed to install:<br />
cryptonite-0.15 depends on memory-0.12 which failed to install.<br />
memory-0.12 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
I haven't been able to figure out exactly what's going on there.<br />
<br />
Or, <code>mcabal install aeson</code> fails with:<br />
<br />
<pre><br />
Building aeson-0.11.1.4...<br />
Preprocessing library aeson-0.11.1.4...<br />
ghc: Data/Aeson/TH.hs:9:14-28: Template Haskell requires GHC with interpreter support<br />
Perhaps you are using a stage-1 compiler?<br />
Usage: For basic information, try the `--help' option.<br />
Failed to install aeson-0.11.1.4<br />
cabal: Error: some packages failed to install:<br />
aeson-0.11.1.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
== Native GHC for musl ==<br />
<br />
Given the issues with cabal and Template Haskell when cross-compiling, the best solution (for x86_64, at least) may be a native GHC compiler which is linked against musl.<br />
<br />
[https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html Marios Titas has a haskell-cafe post] and a [https://github.com/redneb/ghc-alt-libc/ github repository] about a musl-native ghc toolchain.<br />
<br />
If you prefer Docker over chroot, there is [https://hub.docker.com/r/nilcons/ghc-musl/ a Docker image] based on [https://alpinelinux.org/about/ Alpine Linux], and the corresponding Dockerfile is [https://github.com/nilcons/ghc-musl on github].<br />
<br />
<br />
[[Category:OS]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=OpenWRT&diff=60685OpenWRT2016-04-18T05:56:54Z<p>Ppelleti: a collection of notes about running Haskell programs on OpenWRT</p>
<hr />
<div>This page attempts to explain various strategies for getting Haskell programs to run on [https://openwrt.org/ OpenWRT]. Since (AFAIK?) no attempt has been made to integrate ghc into [https://wiki.openwrt.org/doc/howto/build OpenWRT's buildroot], the strategies here are pretty much synonymous with [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling cross-compiling] and static linking Haskell programs in general, and are not specific to OpenWRT.<br />
<br />
== Cross-compiling for MIPS ==<br />
<br />
[https://github.com/wereHamster/onion-omega wereHamster has a github repository] of Dockerfiles for building a GHC cross-compiler for the [https://onion.io/omega Onion Omega].<br />
<br />
== Cross-compiling for x86_64 ==<br />
<br />
(Apologies for the first-person nature of the text; I originally wrote it as a blog post. Please feel free to edit it to be more third-person and wiki-appropriate.)<br />
<br />
I'd like to be able to run Haskell programs on my OpenWRT box.<br />
Since my OpenWRT box has an x86_64 processor, it could almost run the<br />
same binaries that my desktop Linux machine does. However, the reason<br />
it can't is because it uses a different C library. Desktop Linux<br />
(specifically Ubuntu in my case) uses glibc. OpenWRT used uclibc in<br />
past versions, and uses [http://www.musl-libc.org/ musl] on trunk. Since binaries are<br />
normally linked dynamically (and in the case of glibc, they pretty<br />
much have to be), the target machine needs to have the same C library<br />
that the executable was built with.<br />
<br />
One approach would be to dynamically link against the C library that<br />
OpenWRT uses. However, an even more robust approach is to link the<br />
executable statically. Then it can run on ''any'' x86_64 Linux machine,<br />
regardless of what libraries it has installed.<br />
<br />
Unfortunately, glibc doesn't really work correctly with fully static<br />
linking. Therefore, another C library needs to be used. The best<br />
choice seems to be musl. Coincidentally, musl is also the C library<br />
used by OpenWRT trunk, but since we're going to link statically, it<br />
wouldn't have to be.<br />
<br />
So, how do we compile and link Haskell programs against musl? One<br />
approach is to use [https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html a musl version of ghc]. Unfortunately, that<br />
approach requires a full musl-based Linux system to run on. The<br />
author of that post recommends a musl-based Gentoo distribution, but<br />
that seemed kind of icky to me. I almost could use the OpenWRT box as<br />
the musl-based build system, but that would require a working gcc on<br />
the OpenWRT box. Currently, on OpenWRT trunk,<br />
[https://github.com/openwrt/packages/issues/2244 the gcc package is broken].<br />
<br />
What I really want is a cross-compiler, which will run on my<br />
glibc-based Ubuntu box, but will build executables that use<br />
statically-linked musl. That, in turn, requires having a<br />
cross-compiling toolchain (gcc, binutils, etc.) before building the<br />
ghc cross-compiler. There are several ways to satisfy this<br />
requirement, but after a<br />
[http://mid.gmane.org/CAPabhsKjsMh667uKvBowr0S6OCbK6rZJgaoVPMrfd9_VOAdRMQ@mail.gmail.com recommendation on the haskell-cafe mailing list], I<br />
decided to give [http://crosstool-ng.org/ Crosstool-NG] a try.<br />
<br />
I discovered that, in addition to the packages already installed on my<br />
system, I needed to install these packages in order to get<br />
Crosstool-NG to work:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ sudo apt-get install gperf bison texinfo help2man python-dev<br />
</pre><br />
<br />
So, I got started with Crosstool-NG:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf crosstool-ng-1.22.0.tar.xz<br />
ppelletier@patrick64:~/src$ cd crosstool-ng/<br />
ppelletier@patrick64:~/src/crosstool-ng$ ./configure --prefix=/usr/local<br />
ppelletier@patrick64:~/src/crosstool-ng$ make<br />
ppelletier@patrick64:~/src/crosstool-ng$ sudo make install<br />
ppelletier@patrick64:~/src/crosstool-ng$ mkdir ~/crosstool-ng<br />
ppelletier@patrick64:~/src/crosstool-ng$ cd ~/crosstool-ng<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng x86_64-unknown-linux-gnu<br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng menuconfig<br />
</pre><br />
<br />
In the menuconfig, I selected '''C-library > C library > musl''', and<br />
it's also a good idea to de-select<br />
'''Paths and misc options > Render the toolchain read-only''',<br />
because I'm going to install the GHC cross-compiler in the same<br />
directory tree, so the directories need to be writable.<br />
<br />
Then, I was able to do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/crosstool-ng$ ct-ng build<br />
</pre><br />
<br />
And a little over an hour later, I could do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools$ export PATH="${PATH}:${HOME}/x-tools/x86_64-unknown-linux-musl/bin"<br />
ppelletier@patrick64:~/x-tools$ x86_64-unknown-linux-musl-gcc --version<br />
x86_64-unknown-linux-musl-gcc (crosstool-NG crosstool-ng-1.22.0) 5.2.0<br />
Copyright (C) 2015 Free Software Foundation, Inc.<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />
</pre><br />
<br />
Next, I read [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling the instructions for cross-compiling ghc], and then I<br />
did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src$ curl -O http://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ tar -xf ghc-7.10.3b-src.tar.xz<br />
ppelletier@patrick64:~/src$ cd ghc-7.10.3/<br />
</pre><br />
<br />
And then I attempted to build GHC. I ran into some issues along the<br />
way, so I'm going to present the fixes to those issues now, rather<br />
than reconstructing the exact order in which I did things.<br />
<br />
The main issue is that GHC needs ncurses on the target. I'm not sure<br />
why, but it does. So, I had to go and cross-compile ncurses:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ ./configure --host=x86_64-unknown-linux-musl --prefix=${HOME}/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ncurses-6.0$ make<br />
</pre><br />
<br />
Well, that ended up failing with:<br />
<br />
<pre><br />
x86_64-unknown-linux-musl-gcc -DHAVE_CONFIG_H -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -c ../ncurses/lib_gen.c -o ../objects/lib_gen.o<br />
In file included from ./curses.priv.h:325:0,<br />
from ../ncurses/lib_gen.c:19:<br />
_20591.c:843:15: error: expected ')' before 'int'<br />
../include/curses.h:1631:56: note: in definition of macro 'mouse_trafo'<br />
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)<br />
^<br />
make[1]: *** [../objects/lib_gen.o] Error 1<br />
make[1]: Leaving directory `/home/ppelletier/src/ncurses-6.0/ncurses'<br />
make: *** [all] Error 2<br />
</pre><br />
<br />
I found the answer in [https://github.com/wereHamster/onion-omega/blob/master/ghc/Dockerfile wereHamster's Dockerfile]. In<br />
<code>ncurses/base/MKlib_gen.sh</code>, line 65 needs to be changed from:<br />
<br />
<pre><br />
preprocessor="$1 -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
to:<br />
<br />
<pre><br />
preprocessor="$1 -P -DNCURSES_INTERNALS -I../include"<br />
</pre><br />
<br />
Okay, now the <code>make</code> succeeds, and after <code>make</code>, I do:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ncurses-6.0$ make install<br />
</pre><br />
<br />
However, this is not enough. I thought that by installing it under<br />
the cross toolchain's prefix, gcc would automatically pick up the<br />
ncurses includes. But it didn't. So, I need to specify<br />
<code>--with-curses-includes</code> and <code>--with-curses-libraries</code> to ghc's<br />
<code>configure</code>. Unfortunately, there doesn't seem to be a single value<br />
that works for <code>--with-curses-includes</code>, and it doesn't seem to be<br />
possible to specify more than one value for <code>--with-curses-includes</code>.<br />
<br />
If I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include</code>,<br />
then the build is unable to find <code>ncurses.h</code>. However, if I use<br />
<code>--with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses</code>,<br />
then <code>ncurses.h</code> includes <code>ncurses/ncurses_dll.h</code>, which is not<br />
found. My really ugly solution was:<br />
<br />
<pre><br />
ppelletier@patrick64:~/x-tools/x86_64-unknown-linux-musl/include/ncurses$ ln -s . ncurses<br />
</pre><br />
<br />
Now we're ready to actually build ghc successfully. In the<br />
<code>~/src/ghc-7.10.3/mk</code> directory, I copied <code>build.mk.sample</code> to<br />
<code>build.mk</code>, and then uncommented <code>BuildFlavour = quick-cross</code>. Next<br />
I did:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/ghc-7.10.3$ ./configure --target=x86_64-unknown-linux-musl --with-curses-includes=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/include/ncurses --with-curses-libraries=/home/ppelletier/x-tools/x86_64-unknown-linux-musl/lib --prefix=/home/ppelletier/x-tools/x86_64-unknown-linux-musl<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make<br />
ppelletier@patrick64:~/src/ghc-7.10.3$ make install<br />
</pre><br />
<br />
It turns out that this toolchain still links dynamically by default,<br />
so I have to specify <code>-static -optl-static</code> when compiling Haskell<br />
programs. For example:<br />
<br />
<pre><br />
ppelletier@patrick64:~/programming/haskell$ x86_64-unknown-linux-musl-ghc -O -static -optl-static contact.hs<br />
[1 of 1] Compiling Main ( contact.hs, contact.o )<br />
Linking contact ...<br />
ppelletier@patrick64:~/programming/haskell$ file contact<br />
contact: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped<br />
ppelletier@patrick64:~/programming/haskell$ ldd contact<br />
not a dynamic executable<br />
</pre><br />
<br />
The <code>contact</code> executable can now be run on either my Ubuntu box or my<br />
OpenWRT box.<br />
<br />
However, in order to build nontrivial programs, I need cabal. The [https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling GHC cross-compiling page] recommends:<br />
<br />
<pre><br />
cabal --with-ghc=<cross-ghc> --with-ld=<ld> ...<br />
</pre><br />
<br />
So I expanded this approach to:<br />
<br />
<pre><br />
alias mcabal="cabal --with-ghc=x86_64-unknown-linux-musl-ghc --with-ld=x86_64-unknown-linux-musl-ld --with-gcc=x86_64-unknown-linux-musl-gcc --with-ghc-pkg=x86_64-unknown-linux-musl-ghc-pkg --disable-executable-dynamic"<br />
</pre><br />
<br />
I'm able to install some packages with mcabal. (For example, <code>mcabal install hourglass</code>.)<br />
<br />
But with cryptonite, I get:<br />
<br />
<pre><br />
ppelletier@patrick64:~/src/lifx/lifx-programs$ mcabal install --flags=-integer-gmp cryptonite<br />
Resolving dependencies...<br />
Configuring memory-0.12...<br />
Building memory-0.12...<br />
Preprocessing library memory-0.12...<br />
running dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make failed (exit code 127)<br />
command was: dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix_hsc_make >dist/dist-sandbox-5f352b7e/build/Data/Memory/MemMap/Posix.hs<br />
Failed to install memory-0.12<br />
cabal: Error: some packages failed to install:<br />
cryptonite-0.15 depends on memory-0.12 which failed to install.<br />
memory-0.12 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
I haven't been able to figure out exactly what's going on there.<br />
<br />
Or, <code>mcabal install aeson</code> fails with:<br />
<br />
<pre><br />
Building aeson-0.11.1.4...<br />
Preprocessing library aeson-0.11.1.4...<br />
ghc: Data/Aeson/TH.hs:9:14-28: Template Haskell requires GHC with interpreter support<br />
Perhaps you are using a stage-1 compiler?<br />
Usage: For basic information, try the `--help' option.<br />
Failed to install aeson-0.11.1.4<br />
cabal: Error: some packages failed to install:<br />
aeson-0.11.1.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
</pre><br />
<br />
== Native GHC for musl ==<br />
<br />
Given the issues with cabal and Template Haskell when cross-compiling, the best solution (for x86_64, at least) may be a native GHC compiler which is linked against musl.<br />
<br />
[https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html Marios Titas has a haskell-cafe post] and a [https://github.com/redneb/ghc-alt-libc/ github repository] about a musl-native ghc toolchain.<br />
<br />
If you prefer Docker over chroot, there is [https://hub.docker.com/r/nilcons/ghc-musl/ a Docker image] based on [https://alpinelinux.org/about/ Alpine Linux], and the corresponding Dockerfile is [https://github.com/nilcons/ghc-musl on github].</div>Ppelletihttps://wiki.haskell.org/index.php?title=Import_modules_properly&diff=59707Import modules properly2015-05-02T08:28:17Z<p>Ppelleti: /* Introduction */ minor typos</p>
<hr />
<div>== Introduction ==<br />
<br />
Haskell has a lot of variants of [[Import|importing]] identifiers from other modules.<br />
However not all of them are as comfortable as they seem to be at the first glance.<br />
We recommend to focus on the following two forms of import:<br />
<haskell><br />
import qualified Very.Special.Module as VSM<br />
import Another.Important.Module (printf, (<|>), )<br />
</haskell><br />
instead of<br />
<haskell><br />
import Very.Special.Module<br />
import Another.Important.Module hiding (open, close, )<br />
</haskell><br />
<br />
There are four different kind of reasons for this.<br />
<br />
* '''Style:''' If you read <hask>printf</hask>, <hask><|></hask> or <hask>VSM.open</hask> in the program you can find out easily where the identifier comes from. In the second case you don't know if these identifiers are from <hask>Very.Special.Module</hask>, <hask>Another.Important.Module</hask> or even other modules. Mind you that grep won't help, because <hask>Very.Special.Module</hask> and <hask>Another.Important.Module</hask> might just re-export other modules. You might guess the origin of <hask>printf</hask> according to its name, but for the infix operator <hask><|></hask> you will certainly have no idea.<br />
* '''Compatibility:''' In the second case, if new identifiers are added to the imported modules they might clash with names of other modules. Thus updating imported modules may break your code. If you import a package A with version a.b.c.d that follows the [[Package versioning policy]] then within versions with the same a.b it is allowed to add identifiers. This means that if you import the suggested way, you can safely specify <code>A >= a.b.c && <a.b+1</code> in your [[Cabal]] file. Otherwise you have to choose the smaller range <code>A >= a.b.c && <a.b.c+1</code>. It may also be that <hask>Another.Important.Module.open</hask> was deprecated when you hid it, and with a module update removing that identifier, your import fails. That is, an identifier that you never needed but only annoyed you, annoys you again, when it was meant to not bother you any longer! The first variant of import does not suffer from these problems.<br />
* '''Correctness:''' I once found a bug in the StorableVector package by converting anonymous imports to explicit imports. I found out that the function <hask>Foreign.Ptr.plusPtr</hask> was imported, although functions from this module always have to calculate with unit "element" not "byte". That is, <hask>advancePtr</hask> must be used instead. Actually, the <hask>reverse</hask> function used <hask>plusPtr</hask> and this was wrong. A misbehaviour could only be observed for sub-vectors and elements with size greater than 1 byte. The test suite did miss that.<br />
* '''Maintenance:''' All too often I find an old module that cannot be compiled any longer since it uses identifiers that do no longer exist. If the module imports implicitly and without qualification I have little chance to find out where the identifiers originally came from, what they meant and how they must be replaced.<br />
<br />
== Exception from the rule ==<br />
<br />
Since the Prelude is intended to be fixed for the future, it should be safe to use the <hask>hiding</hask> clause when importing <hask>Prelude</hask>.<br />
Actually if you do not mention Prelude it will be imported anonymously.<br />
<br />
== Clashing of module name abbreviations ==<br />
<br />
In Haskell it is possible to use the same abbreviation for different modules:<br />
<haskell><br />
import qualified Data.List as List<br />
import qualified Data.List.Extra as List<br />
</haskell><br />
This is discouraged for the same reasons as above:<br />
<br />
* '''Style''': The identifier <hask>List.intercalate</hask> may refer to either <hask>Data.List</hask> or <hask>Data.List.Extra</hask>. The reader of that module has to check these modules in order to find it out.<br />
<br />
* '''Compatibility''': The function <hask>List.intercalate</hask> may be currently defined only in <hask>Data.List.Extra</hask>. However after many people found it useful, it is also added to <hask>Data.List</hask>. Then <hask>List.intercalate</hask> can no longer be resolved.<br />
<br />
== Counter-arguments to explicit import lists ==<br />
<br />
The issue of whether to use explicit import lists is not always clear-cut, however.<br />
Here are some reasons you might not want to do this:<br />
<br />
* Development is slower: almost every change is accompanied by an import list change, especially if you want to keep your code warning-clean.<br />
<br />
* When working on a project with multiple developers, explicit import lists can cause spurious conflicts, since two otherwise-unrelated changes to a file may both require changes to the same import list.<br />
<br />
For these reasons amongst others, the GHC project decided to drop the use of explicit import lists.<br />
We recommend using explicit import lists when importing from other packages,<br />
but not when importing modules within the same package.<br />
<br />
Qualified use of identifiers does not suffer from the above problems.<br />
<br />
== See also ==<br />
<br />
* [[Qualified names]]<br />
<br />
* {{HackagePackage|id=check-pvp}} is a program that checks for consistency between package dependencies and import style.<br />
<br />
{{essay}}<br />
<br />
[[Category:Style]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=WxHaskell/Documentation&diff=58842WxHaskell/Documentation2014-09-19T22:21:15Z<p>Ppelleti: /* Documentation */ remove fragment, because wxhaskell was obscured by the Wayback toolbar</p>
<hr />
<div>=== Documentation ===<br />
<br />
; [http://web.archive.org/web/20120211184204/http://legacy.cs.uu.nl/daan/download/papers/wxhaskell.pdf wxHaskell - A Portable and Concise GUI Library for Haskell] (PDF)<br />
: This documents introduces wxHaskell and describes how to create a game ([[wxAsteroids]]) <br />
<br />
(All of the following links are cheap to follow)<br />
<br />
; [http://hackage.haskell.org/package/wx wx haddock] (see also [http://hackage.haskell.org/package/wxcore wxcore])<br />
: The haddock generated documentation of the wxHaskell libraries. You can browse some wxHaskell [http://darcs.haskell.org/wxhaskell/samples/wx/ examples] in the darcs repository. Documentation and samples are also distributed as a single zip file on the [[WxHaskell/Download|download]] page.<br />
; [http://www.wxwidgets.org wxWidgets]<br />
: The documentation of the wxWidgets library itself is invaluable when writing more advanced applications. On windows you can find the documentation in ''html help'' format in the download section – this is a particularly convenient way to browse the documentation.<br />
; [[WxHaskell/Quickstart|Quick start]]<br />
: A guide that gets you started with wxHaskell quickly.<br />
; [[WxHaskell/FAQ|Faq]]<br />
: Frequently asked questions.<br />
; [http://web.archive.org/web/20120401040839/http://legacy.cs.uu.nl/daan/pubs.html Article]<br />
: An article about the design of wxHaskell, published in the proceedings of the Haskell workshop 2004.<br /><br />
:PDF file: [http://web.archive.org/web/20120211184204/http://legacy.cs.uu.nl/daan/download/papers/wxhaskell.pdf wxHaskell - A portable and concise GUI library for Haskell].<br />
; [[WxHaskell/License|License]]<br />
: Describes the licensing conditions of wxHaskell.<br />
; [http://sourceforge.net/mail/?group_id=73133 wxHaskell mailing lists]<br />
: Mailing lists about wxHaskell<br />
; [http://haskell.org/haskellwiki/WxHaskell wxHaskell Wiki]<br />
: A Wiki site for wxHaskell where everyone can add useful content, like hints, articles, example programs etc.<br />
[[Category:wxHaskell|Documentation]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=WxHaskell/Documentation&diff=58841WxHaskell/Documentation2014-09-19T22:13:32Z<p>Ppelleti: /* Documentation */ link to paper was dead</p>
<hr />
<div>=== Documentation ===<br />
<br />
; [http://web.archive.org/web/20120211184204/http://legacy.cs.uu.nl/daan/download/papers/wxhaskell.pdf wxHaskell - A Portable and Concise GUI Library for Haskell] (PDF)<br />
: This documents introduces wxHaskell and describes how to create a game ([[wxAsteroids]]) <br />
<br />
(All of the following links are cheap to follow)<br />
<br />
; [http://hackage.haskell.org/package/wx wx haddock] (see also [http://hackage.haskell.org/package/wxcore wxcore])<br />
: The haddock generated documentation of the wxHaskell libraries. You can browse some wxHaskell [http://darcs.haskell.org/wxhaskell/samples/wx/ examples] in the darcs repository. Documentation and samples are also distributed as a single zip file on the [[WxHaskell/Download|download]] page.<br />
; [http://www.wxwidgets.org wxWidgets]<br />
: The documentation of the wxWidgets library itself is invaluable when writing more advanced applications. On windows you can find the documentation in ''html help'' format in the download section – this is a particularly convenient way to browse the documentation.<br />
; [[WxHaskell/Quickstart|Quick start]]<br />
: A guide that gets you started with wxHaskell quickly.<br />
; [[WxHaskell/FAQ|Faq]]<br />
: Frequently asked questions.<br />
; [http://web.archive.org/web/20120401040839/http://legacy.cs.uu.nl/daan/pubs.html#wxhaskell Article]<br />
: An article about the design of wxHaskell, published in the proceedings of the Haskell workshop 2004.<br /><br />
:PDF file: [http://web.archive.org/web/20120211184204/http://legacy.cs.uu.nl/daan/download/papers/wxhaskell.pdf wxHaskell - A portable and concise GUI library for Haskell].<br />
; [[WxHaskell/License|License]]<br />
: Describes the licensing conditions of wxHaskell.<br />
; [http://sourceforge.net/mail/?group_id=73133 wxHaskell mailing lists]<br />
: Mailing lists about wxHaskell<br />
; [http://haskell.org/haskellwiki/WxHaskell wxHaskell Wiki]<br />
: A Wiki site for wxHaskell where everyone can add useful content, like hints, articles, example programs etc.<br />
[[Category:wxHaskell|Documentation]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=WxHaskell/Mac&diff=58835WxHaskell/Mac2014-09-19T05:59:46Z<p>Ppelleti: /* Known working configurations */ with HP 2014.2.0.0</p>
<hr />
<div>== Installing on MacOS X ==<br />
<br />
<ol><br />
<li> Install the Developer Tools<br />
<li> Install wxWidgets 2.9 by hand<br />
<ul><br />
<li>If you use the [http://mxcl.github.com/homebrew/ HomeBrew] package manager:<br />
<br><code>brew install wxmac --devel</code><br />
<br>or on Lion, possibly <code>brew install wxmac --use-llvm --devel</code><br />
<li>If you use the [http://www.macports.org/ MacPorts] package manager:<br><br />
<code><br />
sudo port install wxWidgets-devel +universal<br />
</code><br />
<li>Manual installation is not recommended, but if you want to do it anyway, download the source code and install it with the following flags<br />
<pre><br />
./configure --enable-unicode --disable-debug --with-osx_cocoa<br />
--prefix=/usr/local --enable-stc --enable-aui<br />
--enable-propgrid --enable-xrc --enable-ribbon<br />
--enable-richtext --enable-webkit --with-opengl<br />
make && make install<br />
</pre><br />
</ul><br />
<li> (OS X 10.6 or below) Check your path to make sure you are using your wxWidgets and not the default Mac one. The command<br />
<br><br />
<code>which wx-config</code><br />
<br>should ''not'' return the file path <code>/usr/bin/wx-config</code>.<br />
<li>Now it's time to install the wxHaskell libraries proper:<br />
<br><br />
<code>cabal install wx cabal-macosx</code><br />
<li>Compile and run a [https://raw.github.com/jodonoghue/wxHaskell/master/samples/wxcore/HelloWorld.hs sample wxcore application]:<br />
<br><pre>ghc --make HelloWorld.hs<br />
macosx-app HelloWorld<br />
./HelloWorld.app/Contents/MacOS/HelloWorld<br />
</pre>(see note 2012-04-24-MacPorts if you use MacPorts)<br />
</li><br />
</ol><br />
<br />
== Known working configurations ==<br />
<br />
{|<br />
!|Date<br />
!|Arch<br />
!|OS/XCode<br />
!|GHC<br />
!|Haskell Platform<br />
!|wxWidgets<br />
!|wxHaskell<br />
|-<br />
|2012-04<br />
|Intel 64-bit<br />
|Lion (10.7.3), XCode 4.3<br />
|7.4.1<br />
|<br />
|2.9.3 (HomeBrew)<br />
|0.90 (see notes)<br />
|-<br />
|2012-04<br />
|Intel 64-bit<br />
|Lion (10.7.3), Xcode 4.3<br />
|7.0.4<br />
|2011.4.0.0<br />
|2.9.3 (HomeBrew)<br />
|0.90<br />
|-<br />
|2012-04<br />
|Intel 32-bit<br />
|Snow Leopard (10.6.8), Xcode 3.2.6<br />
|7.0.4<br />
|2011.4.0.0<br />
|2.9.3 (MacPorts)<br />
|0.90 (see notes)<br />
|-<br />
|2012-11<br />
|Intel 64-bit<br />
|Mountain Lion (10.8.2), Xcode 4.5.2<br />
|7.4.2<br />
|2012.4.0.0<br />
|2.9.4 <br />
|0.90.0.1 (see notes)<br />
|-<br />
|2013-03<br />
|Intel 64-bit<br />
|Mountain Lion (10.8.3), Xcode 4.6.1<br />
|7.4.2<br />
|2012.4.0.0 (64)<br />
|2.9.4 <br />
|0.90.0.1 <br />
|-<br />
|2014-07<br />
|Intel 64-bit<br />
|Mavericks (10.9.3), Xcode 5.1.1 (ggc 4.8 from Macports)<br />
|7.6.3<br />
|2013.2.0.0 (64)<br />
|3.0.0 (Macports wxWidgets-3.0)<br />
|0.91.0.0 (from Github)<br />
|-<br />
|2014-09<br />
|Intel 64-bit<br />
|Mavericks (10.9.4), Xcode 5.1.1<br />
|7.8.3<br />
|2014.2.0.0<br />
|3.0.0 (HomeBrew)<br />
|0.91.0.0<br />
|}<br />
<br />
== Notes ==<br />
<br />
These notes tend to be a bit ephemeral and are thus dated to help you figure out if they may still apply or not.<br />
<br />
* 2012-04-24 MacPorts: If you use MacPorts, you may run into a problem with the iconv library. Tell GHC that you prefer the system libraries first: <code>ghc HelloWorld.hs -L/usr/lib</code><br />
* 2012-04-17: The MacPorts version of wxWidgets 2.9.3 can be used. I added a few flags to the Portfile, but they are probably not necessary.<br />
* 2012-04-14: On MacOS X Lion, to install wxWidgets 2.9 with HomeBrew, you may need to run <code>brew install wxmac --use-llvm --devel</code><br />
* 2014-07-17: See https://sourceforge.net/p/wxhaskell/bugs/93/#715b for more information.<br />
<br />
== Using wxHaskell on MacOS X platforms ==<br />
<br />
Even though graphical applications on MacOS X look great, it is a still a developers nightmare to get them working :-). This page describes how to circumvent some of the pitfalls.<br />
<br />
<ul><br />
<li>Executables generated with GHC do not work when executed directly if they use the graphical API; they need to be upgraded into so called [https://en.wikipedia.org/wiki/Application_Bundle application bundles] for MacOS X. Use the [https://github.com/gimbo/cabal-macosx cabal-macosx] package to automate this. It can be integrated with Cabal and/or used as a standalone <code>macosx-app</code> script.<br />
</li><br />
<li><p>''Note: The following no longer applies to <code>wxcore >= 0.90.0.1</code>.''</p><br />
<p>Due to complicated MacOS X restrictions, graphical wxHaskell applications do not work directly when used from GHCi. Fortunately, Wolfgang Thaller has kindly provided an ingenious [http://wxhaskell.sourceforge.net/download/EnableGUI.hs Haskell module] that solves this problem. Just import the (compiled) module [http://wxhaskell.sourceforge.net/download/EnableGUI.hs <tt>EnableGUI</tt>] in your program and issue the following command to run <tt>main</tt> from your GHCi prompt:</p><br />
<pre>&gt; enableGUI &gt;&gt; main</pre><br />
<p>Compiling and using enableGUI needs some command line flags:</p><br />
<pre>&gt; ghc -XForeignFunctionInterface -c EnableGUI.hs<br />
&gt; ghci -framework Carbon HelloWorld.hs<br />
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help<br />
Loading package base ... linking ... done.<br />
Loading object (framework) Carbon ... done<br />
final link ... done<br />
[2 of 2] Compiling Main ( Main.hs, interpreted )<br />
Ok, modules loaded: Main, EnableGUI.<br />
*Main&gt; enableGUI<br />
*Main&gt; main</pre><br />
</li><br />
</ul><br />
<br />
== Troubleshooting ==<br />
<br />
See [[../Troubleshooting]] for help getting your wxhaskell applications running<br />
<br />
<ul><li><p>The dynamic link libraries used by wxHaskell can not always be found. If your application seems to start (the icon bounces) but terminates mysteriously, you need to set the dynamic link library search path to the wxHaskell library directory. For example:</p><br />
<pre>&gt; setenv DYLD_LIBRARY_PATH /usr/local/wxhaskell/lib</pre><br />
<br />
or <br />
<br />
<pre>&gt; setenv DYLD_LIBRARY_PATH $HOME/.cabal/local/lib/wxhaskell-0.11.0/lib</pre><br />
<br />
or (MacOSX Lion tested only)<br />
<br />
Copy (and patch) shared libraries into the app bundle using macosx-make-standalone [http://hackage.haskell.org/package/macosx-make-standalone]<br />
<br />
</li></li></ul><br />
<br />
<br />
[[Category:wxHaskell|MacOS X]]</div>Ppelletihttps://wiki.haskell.org/index.php?title=GHC/Memory_Management&diff=38431GHC/Memory Management2011-02-01T02:52:55Z<p>Ppelleti: /* Garbage collection */ "pointer to" -> "pointed to"</p>
<hr />
<div>Haskell computations produce a lot of memory garbage - much more than conventional imperative languages. It's because data are immutable so the only way to store every next operation's result is to create new value. In particular, every iteration of a recursive computation creates a new values. But GHC is able to efficiently manage garbage collection, so it's not uncommon to produce 1gb of data per second (most part of which will be garbage collected immediately). So, you may be interested to learn how GHC does such a good job.<br />
<br />
<br />
== Motivating examples ==<br />
<br />
Through the article, we will use two motivating examples. The first one just computes some value:<br />
<br />
<haskell><br />
factorial 0 acc = acc<br />
factorial n acc = factorial (n-1) $! (acc*n)<br />
</haskell><br />
<br />
Note that we have used accumulator with strict evaluation in order to suppress the default laziness of Haskell computations - this code really computes new n and acc on every recursion step.<br />
<br />
<br />
Our second example produces a large list:<br />
<br />
<haskell><br />
upto i n | i<=n = i : upto (i+1) n<br />
| otherwise = []<br />
</haskell><br />
<br />
<br />
So, we have two examples - one that produces just one value but leaves a lot of garbage and another producing a lot of live data.<br />
<br />
== Garbage collection ==<br />
<br />
Haskell's computation model is very different from that of conventional mutable languages. Data immutability forces us to produce a lot of temporary data but it also helps to collect this garbage rapidly. The trick is that immutable data NEVER points to younger values. Indeed, younger values don't yet exist at the time when an old value is created, so it cannot be pointed to from scratch. And since values are never modified, neither can it be pointed to later. This is the key property of immutable data.<br />
<br />
This greatly simplifies garbage collection (GC). At anytime we can scan the last values created and free those that are not pointed to from the same set (of course, real roots of live values hierarchy are live in the stack). It is how things work: by default, GHC uses generational GC. New data are allocated in 512kb "nursery". Once it's exhausted, "minor GC" occurs - it scans the nursery and frees unused values. Or, to be exact, it copies live values to the main memory area. The fewer values that survive - the less work to do. If you have, for example, a recursive algorithm that quickly filled the nursery with generations of its induction variables - only the last generation of the variables will survive and be copied to main memory, the rest will be not even touched! So it has a counter-intuitive behavior: the larger percent of your values are garbage - the faster it works.<br />
<br />
== Further reading ==<br />
[http://www.haskell.org/~simonmar/bib/parallel-gc-08_abstract.html Parallel Generational-Copying Garbage Collection with a Block-Structured Heap (2008)]</div>Ppelleti