diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-02-17 10:18:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 10:18:42 +0100 |
commit | 54ab377288b3cba6f36e2e85b7aaeb32ffa639e0 (patch) | |
tree | c058319188fbc496752409bd418b6f773e1b4e89 /doc/manual | |
parent | 4e98f0345c144b9d85bed1f6b0bc509bf7ddc000 (diff) | |
parent | 5f4701e70d35bb9ea2fb659caf387a30001e28ce (diff) |
Merge pull request #4553 from mausch/patch-1
Fix Haskell example
Diffstat (limited to 'doc/manual')
-rw-r--r-- | doc/manual/src/command-ref/nix-shell.md | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/doc/manual/src/command-ref/nix-shell.md b/doc/manual/src/command-ref/nix-shell.md index 88b675e71..54812a49f 100644 --- a/doc/manual/src/command-ref/nix-shell.md +++ b/doc/manual/src/command-ref/nix-shell.md @@ -232,22 +232,23 @@ terraform apply > in a nix-shell shebang. Finally, using the merging of multiple nix-shell shebangs the following -Haskell script uses a specific branch of Nixpkgs/NixOS (the 18.03 stable +Haskell script uses a specific branch of Nixpkgs/NixOS (the 20.03 stable branch): ```haskell #! /usr/bin/env nix-shell -#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (ps: [ps.HTTP ps.tagsoup])" -#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-18.03.tar.gz +#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (ps: [ps.download-curl ps.tagsoup])" +#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.03.tar.gz -import Network.HTTP +import Network.Curl.Download import Text.HTML.TagSoup +import Data.Either +import Data.ByteString.Char8 (unpack) -- Fetch nixos.org and print all hrefs. main = do - resp <- Network.HTTP.simpleHTTP (getRequest "http://nixos.org/") - body <- getResponseBody resp - let tags = filter (isTagOpenName "a") $ parseTags body + resp <- openURI "https://nixos.org/" + let tags = filter (isTagOpenName "a") $ parseTags $ unpack $ fromRight undefined resp let tags' = map (fromAttrib "href") tags mapM_ putStrLn $ filter (/= "") tags' ``` |