Haskell: Difference between revisions

DHCP (talk | contribs)
m Using shellFor (multiple packages): do we use lang="haskell" for cabal syntax highlighting???
DHCP (talk | contribs)
m Scripting: fix indentation
 
Line 32: Line 32:


To remove the additional latency overhead of a nix-shell, add GHC to <code>environment.systemPackages</code> and call <code>runghc</code> in the shebang.<syntaxhighlight lang="nix">
To remove the additional latency overhead of a nix-shell, add GHC to <code>environment.systemPackages</code> and call <code>runghc</code> in the shebang.<syntaxhighlight lang="nix">
  environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
    ...
  ...
    (ghc.withPackages (hsPkgs: with hsPkgs; [
  (ghc.withPackages (hsPkgs: with hsPkgs; [
      turtle      # Faster startup time with all external shell commands
    turtle      # Faster startup time with all external shell commands
      shh        # Piping operators and other goodies
    shh        # Piping operators and other goodies
      shh-extras  # Try shh as an interactive shell
    shh-extras  # Try shh as an interactive shell
      ...        # ...anything else you want!
    ...        # ...anything else you want!
    ])
  ])
  ];  
];
</syntaxhighlight>Here's a basic example using the Shh module rather than Turtle, so it can use the pipe operator:<syntaxhighlight lang="haskell">
</syntaxhighlight>Here's a basic example using the Shh module rather than Turtle, so it can use the pipe operator:<syntaxhighlight lang="haskell">
#!/usr/bin/env runghc
#!/usr/bin/env runghc