1
0
mirror of https://github.com/bennofs/nix-script synced 2025-01-09 20:34:20 +01:00

fixes for haskellng + add example

This commit is contained in:
Benno Fünfstück 2015-08-29 20:35:53 +02:00
parent 45f2a37b67
commit d28f2a06ea
3 changed files with 11 additions and 4 deletions

View File

@ -25,7 +25,7 @@ Usage
To use `nix-script`, you need to add a header to your file. Here is an example for a haskell file `example.hs`:
```haskell
#!nix-script
#!/usr/bin/env nix-script
#!> haskell
#! haskell | text lens optparse-applicative
#! shell | nix nix-prefetch-scripts

8
example.hs Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env nix-script
#!> haskell
#! haskell | text lens optparse-applicative
#! shell | nix nix-prefetch-scripts
main :: IO ()
main = do
putStrLn "It works!"

5
nix-script.hs Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!nix-bang
#!/usr/bin/env nix-script
#!> haskell
#! haskell | text lens
#! shell | nix
@ -37,8 +37,7 @@ languages = [haskell, shell]
haskell :: LangDef
haskell = LangDef "haskell" d r i where
d pkgs = return $
"haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords (map mkPkg pkgs) <> "])"
mkPkg = Text.concat . over (_tail.mapped._head) toUpper . Text.splitOn "-"
"haskellPackages.ghcWithPackages (hs: with hs; [" <> Text.unwords pkgs <> "])"
r script = ("runhaskell" , [script])
i script = ("ghci" , [script])