mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
tests: Add a cabal new-build project
This commit is contained in:
parent
b060ea5576
commit
dd1baeb287
2
test/shell-for/cabal.project
Normal file
2
test/shell-for/cabal.project
Normal file
@ -0,0 +1,2 @@
|
||||
packages: pkga
|
||||
pkgb
|
16
test/shell-for/pkga/PkgA.hs
Normal file
16
test/shell-for/pkga/PkgA.hs
Normal 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))
|
2
test/shell-for/pkga/Setup.hs
Normal file
2
test/shell-for/pkga/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
20
test/shell-for/pkga/pkga.cabal
Normal file
20
test/shell-for/pkga/pkga.cabal
Normal 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
|
2
test/shell-for/pkgb/Setup.hs
Normal file
2
test/shell-for/pkgb/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
10
test/shell-for/pkgb/app/Main.hs
Normal file
10
test/shell-for/pkgb/app/Main.hs
Normal 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
|
36
test/shell-for/pkgb/pkgb.cabal
Normal file
36
test/shell-for/pkgb/pkgb.cabal
Normal 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
|
21
test/shell-for/pkgb/src/ConduitExample.hs
Normal file
21
test/shell-for/pkgb/src/ConduitExample.hs
Normal 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"
|
7
test/shell-for/pkgb/src/PkgB.hs
Normal file
7
test/shell-for/pkgb/src/PkgB.hs
Normal file
@ -0,0 +1,7 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module PkgB (message) where
|
||||
|
||||
import PkgA (decode)
|
||||
|
||||
message = decode "Guvf vf n pnony cebwrpg!"
|
5
test/shell-for/pkgb/src/conduit.hs
Normal file
5
test/shell-for/pkgb/src/conduit.hs
Normal file
@ -0,0 +1,5 @@
|
||||
module Main where
|
||||
|
||||
import ConduitExample
|
||||
|
||||
main = example
|
Loading…
Reference in New Issue
Block a user