Haskell: Difference between revisions

This flow chart is wrong or at least so much oversimplified that it is actively misleading
DHCP (talk | contribs)
m style: add missing "$" prefix, use lang=console, remove unneeded spaces - where needed
Line 23: Line 23:
For redistributable Haskell scripts on any Nix system, you can use a nix-shell shebang.
For redistributable Haskell scripts on any Nix system, you can use a nix-shell shebang.
<syntaxhighlight lang="haskell">#!/usr/bin/env nix-shell
<syntaxhighlight lang="haskell">#!/usr/bin/env nix-shell
#! nix-shell --pure -i runghc -p "ghc.withPackages (pkgs: [ pkgs.turtle ])"
#! nix-shell --pure -i runghc -p "ghc.withPackages (pkgs: [ pkgs.turtle ])"
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
import Turtle
import Turtle
Line 61: Line 61:
[https://www.haskell.org/cabal/ Cabal] is the basic Haskell tool used to configure builds and is internally used by all the Haskell's packaging methods (including stack and nix). If one does not care about the reproducibility/caching offered by nix, it is always possible to use cabal like in a normal system:
[https://www.haskell.org/cabal/ Cabal] is the basic Haskell tool used to configure builds and is internally used by all the Haskell's packaging methods (including stack and nix). If one does not care about the reproducibility/caching offered by nix, it is always possible to use cabal like in a normal system:
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ nix-shell -p "ghc.withPackages (pkgs: [ pkgs.cabal-install ])"
$ nix-shell -p "ghc.withPackages (pkgs: [ pkgs.cabal-install ])"
$ cabal init
$ cabal init
Line 230: Line 230:
* For existing Haskell projects, initialize with:
* For existing Haskell projects, initialize with:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="console">
nix flake init -t github:srid/haskell-flake
$ nix flake init -t github:srid/haskell-flake
</syntaxhighlight>
</syntaxhighlight>


* For new Haskell projects, use the example template:
* For new Haskell projects, use the example template:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="console">
mkdir example && cd ./example
$ mkdir example && cd ./example
nix flake init -t github:srid/haskell-flake#example
$ nix flake init -t github:srid/haskell-flake#example
</syntaxhighlight>
</syntaxhighlight>