mirror of
https://github.com/simplex-chat/haskell.nix.git
synced 2026-06-03 09:17:32 +00:00
f3ea06dcac
For ghc 9.0.2 Haskell.nix will use the `stm`and `filepath` source that came with `ghc` when the version desired matches. This is because 9.0.2 shipped with packages that differ from the same version in hackage. `reinstallableLibGhc` is fixed for GHC 8.10 and above. Rather than including a patch file this works by: * Setting the `subDir` to the `compiler` directory when building. That way relative paths to other parts of the `ghc` source tree (outside the `compiler` directory) still work. * Files that are needed, but generated when `ghc` builds are added from the `generated` output of the ghc derivation. `nonReinstallablePkgs` is now sorted and deduplicated before it is used (this reduces the chance of rebuilds when the list is refactored).
33 lines
862 B
Haskell
33 lines
862 B
Haskell
{-# LANGUAGE CPP #-}
|
|
import Distribution.Simple
|
|
|
|
-- https://github.com/snoyberg/conduit#readme
|
|
|
|
import Conduit
|
|
import System.Directory (removeFile)
|
|
|
|
-- Make sure Cabal and ghc were included
|
|
import Distribution.Package ()
|
|
#if MIN_VERSION_ghc(9,0,0)
|
|
import GHC.SysTools.Ar ()
|
|
#else
|
|
import Ar ()
|
|
#endif
|
|
|
|
example = do
|
|
-- Pure operations: summing numbers.
|
|
print $ runConduitPure $ yieldMany [1..10] .| sumC
|
|
|
|
-- Exception safe file access: copy a file.
|
|
writeFile "input.txt" "This is a test." -- create the source file
|
|
runConduitRes $ sourceFileBS "input.txt" .| sinkFile "output.txt" -- actual copying
|
|
readFile "output.txt" >>= putStrLn -- prove that it worked
|
|
|
|
-- Perform transformations.
|
|
print $ runConduitPure $ yieldMany [1..10] .| mapC (+ 1) .| sinkList
|
|
|
|
removeFile "input.txt"
|
|
removeFile "output.txt"
|
|
|
|
main = defaultMain
|