tests: Add a cabal new-build project

This commit is contained in:
Rodney Lorrimar 2019-05-20 11:08:43 +10:00
parent b060ea5576
commit dd1baeb287
No known key found for this signature in database
GPG Key ID: 2CCD588917A9A868
10 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,2 @@
packages: pkga
pkgb

View File

@ -0,0 +1,16 @@
module PkgA (decode) where
import Control.Lens
import Data.Text.Lens
import Data.Char
import Data.Text (Text)
decode :: Text -> Text
decode = unpacked . mapped %~ rot 13
rot :: Int -> Char -> Char
rot n c | c >= 'a' && c <= 'z' = r 'a' 'z'
| c >= 'A' && c <= 'Z' = r 'A' 'Z'
| otherwise = c
where
r a b = chr $ ord a + ((ord c - ord a + n) `mod` (ord b - ord a + 1))

View File

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

View File

@ -0,0 +1,20 @@
cabal-version: 2.2
-- Initial package description 'pkga.cabal' generated by 'cabal init'. For
-- further documentation, see http://haskell.org/cabal/users-guide/
name: pkga
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
license: LicenseRef-PublicDomain
author: Rodney Lorrimar
maintainer: rodney.lorrimar@iohk.io
category: Testing
library
exposed-modules: PkgA
build-depends: base
, lens
, text
default-language: Haskell2010

View File

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

View File

@ -0,0 +1,10 @@
module Main where
import ConduitExample (example)
import PkgB (message)
import qualified Data.Text.IO as T
main :: IO ()
main = do
T.putStrLn message
example

View File

@ -0,0 +1,36 @@
cabal-version: 2.2
-- Initial package description 'pkgb.cabal' generated by 'cabal init'. For
-- further documentation, see http://haskell.org/cabal/users-guide/
name: pkgb
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
license: LicenseRef-PublicDomain
author: Rodney Lorrimar
maintainer: rodney.lorrimar@iohk.io
category: Testing
library
exposed-modules: ConduitExample
, PkgB
build-depends: base
, pkga
, conduit
, conduit-extra
, directory
, resourcet
hs-source-dirs: src
default-language: Haskell2010
executable pkgb
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base
, pkgb
, optparse-applicative
, text
hs-source-dirs: app
default-language: Haskell2010

View File

@ -0,0 +1,21 @@
-- https://github.com/snoyberg/conduit#readme
module ConduitExample (example) where
import Conduit
import System.Directory (removeFile)
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"

View File

@ -0,0 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
module PkgB (message) where
import PkgA (decode)
message = decode "Guvf vf n pnony cebwrpg!"

View File

@ -0,0 +1,5 @@
module Main where
import ConduitExample
main = example