File tree Expand file tree Collapse file tree 11 files changed +128
-0
lines changed Expand file tree Collapse file tree 11 files changed +128
-0
lines changed Original file line number Diff line number Diff line change
1
+ packages : pkga
2
+ pkgb
Original file line number Diff line number Diff line change
1
+ module PkgA (decode ) where
2
+
3
+ import Control.Lens
4
+ import Data.Text.Lens
5
+ import Data.Char
6
+ import Data.Text (Text )
7
+
8
+ decode :: Text -> Text
9
+ decode = unpacked . mapped %~ rot 13
10
+
11
+ rot :: Int -> Char -> Char
12
+ rot n c | c >= ' a' && c <= ' z' = r ' a' ' z'
13
+ | c >= ' A' && c <= ' Z' = r ' A' ' Z'
14
+ | otherwise = c
15
+ where
16
+ r a b = chr $ ord a + ((ord c - ord a + n) `mod` (ord b - ord a + 1 ))
Original file line number Diff line number Diff line change
1
+ import Distribution.Simple
2
+ main = defaultMain
Original file line number Diff line number Diff line change
1
+ cabal-version : 2.2
2
+ -- Initial package description 'pkga.cabal' generated by 'cabal init'. For
3
+ -- further documentation, see http://haskell.org/cabal/users-guide/
4
+
5
+ name : pkga
6
+ version : 0.1.0.0
7
+ -- synopsis:
8
+ -- description:
9
+ -- bug-reports:
10
+ license : LicenseRef-PublicDomain
11
+ author : Rodney Lorrimar
12
+
13
+ category : Testing
14
+
15
+ library
16
+ exposed-modules : PkgA
17
+ build-depends : base
18
+ , lens
19
+ , text
20
+ default-language : Haskell2010
Original file line number Diff line number Diff line change
1
+ import Distribution.Simple
2
+ main = defaultMain
Original file line number Diff line number Diff line change
1
+ module Main where
2
+
3
+ import ConduitExample (example )
4
+ import PkgB (message )
5
+ import qualified Data.Text.IO as T
6
+
7
+ main :: IO ()
8
+ main = do
9
+ T. putStrLn message
10
+ example
Original file line number Diff line number Diff line change
1
+ cabal-version : 2.2
2
+ -- Initial package description 'pkgb.cabal' generated by 'cabal init'. For
3
+ -- further documentation, see http://haskell.org/cabal/users-guide/
4
+
5
+ name : pkgb
6
+ version : 0.1.0.0
7
+ -- synopsis:
8
+ -- description:
9
+ -- bug-reports:
10
+ license : LicenseRef-PublicDomain
11
+ author : Rodney Lorrimar
12
+
13
+ category : Testing
14
+
15
+ library
16
+ exposed-modules : ConduitExample
17
+ , PkgB
18
+ build-depends : base
19
+ , pkga
20
+ , conduit
21
+ , conduit-extra
22
+ , directory
23
+ , resourcet
24
+ hs-source-dirs : src
25
+ default-language : Haskell2010
26
+
27
+ executable pkgb
28
+ main-is : Main.hs
29
+ -- other-modules:
30
+ -- other-extensions:
31
+ build-depends : base
32
+ , pkgb
33
+ , optparse-applicative
34
+ , text
35
+ hs-source-dirs : app
36
+ default-language : Haskell2010
Original file line number Diff line number Diff line change
1
+ -- https://github.com/snoyberg/conduit#readme
2
+
3
+ module ConduitExample (example ) where
4
+
5
+ import Conduit
6
+ import System.Directory (removeFile )
7
+
8
+ example = do
9
+ -- Pure operations: summing numbers.
10
+ print $ runConduitPure $ yieldMany [1 .. 10 ] .| sumC
11
+
12
+ -- Exception safe file access: copy a file.
13
+ writeFile " input.txt" " This is a test." -- create the source file
14
+ runConduitRes $ sourceFileBS " input.txt" .| sinkFile " output.txt" -- actual copying
15
+ readFile " output.txt" >>= putStrLn -- prove that it worked
16
+
17
+ -- Perform transformations.
18
+ print $ runConduitPure $ yieldMany [1 .. 10 ] .| mapC (+ 1 ) .| sinkList
19
+
20
+ removeFile " input.txt"
21
+ removeFile " output.txt"
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE OverloadedStrings #-}
2
+
3
+ module PkgB (message ) where
4
+
5
+ import PkgA (decode )
6
+
7
+ message = decode " Guvf vf n pnony cebwrpg!"
Original file line number Diff line number Diff line change
1
+ module Main where
2
+
3
+ import ConduitExample
4
+
5
+ main = example
Original file line number Diff line number Diff line change @@ -61,4 +61,11 @@ nix-shell $NIX_BUILD_ARGS \
61
61
--run ' cd shell-for && runghc conduit.hs'
62
62
echo >& 2
63
63
64
+ printf " *** Checking shellFor works for a cabal project...\n" >& 2
65
+ nix-shell $NIX_BUILD_ARGS \
66
+ --pure ./default.nix \
67
+ -A shell-for.env.cabal \
68
+ --run ' cd shell-for && cabal new-build all'
69
+ echo >& 2
70
+
64
71
printf " \n*** Finished successfully\n" >& 2
You can’t perform that action at this time.
0 commit comments