Skip to content

Commit c603b56

Browse files
committed
Add files
1 parent 4641f9c commit c603b56

32 files changed

+17012
-128
lines changed

haskell-reader/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.stack-work/
2+
*~

haskell-reader/.hlint.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# HLint configuration file
2+
# https://github.com/ndmitchell/hlint
3+
##########################
4+
5+
# This file contains a template configuration file, which is typically
6+
# placed as .hlint.yaml in the root of your project
7+
8+
9+
# Warnings currently triggered by your code
10+
- ignore: {name: "Eta reduce"}
11+
12+
13+
# Specify additional command line arguments
14+
#
15+
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
16+
17+
18+
# Control which extensions/flags/modules/functions can be used
19+
#
20+
# - extensions:
21+
# - default: false # all extension are banned by default
22+
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
23+
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
24+
#
25+
# - flags:
26+
# - {name: -w, within: []} # -w is allowed nowhere
27+
#
28+
# - modules:
29+
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
30+
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
31+
#
32+
# - functions:
33+
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
34+
35+
36+
# Add custom hints for this project
37+
#
38+
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
39+
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
40+
41+
42+
# Turn on hints that are off by default
43+
#
44+
# Ban "module X(module X) where", to require a real export list
45+
# - warn: {name: Use explicit module export list}
46+
#
47+
# Replace a $ b $ c with a . b $ c
48+
# - group: {name: dollar, enabled: true}
49+
#
50+
# Generalise map to fmap, ++ to <>
51+
# - group: {name: generalise, enabled: true}
52+
53+
54+
# Ignore some builtin hints
55+
# - ignore: {name: Use let}
56+
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
57+
58+
59+
# Define some custom infix operators
60+
# - fixity: infixr 3 ~^#^~
61+
62+
63+
# To generate a suitable file for HLint do:
64+
# $ hlint --default > .hlint.yaml

haskell-reader/ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog for haskell-reader
2+
3+
## Unreleased changes

haskell-reader/LICENSE

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright Author name here (c) 2021
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Author name here nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

haskell-reader/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# haskell-reader

haskell-reader/Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

haskell-reader/app/Main.hs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Main where
2+
3+
import MyConfig
4+
5+
makeName :: String -> Config String
6+
makeName baseName = do
7+
config <- getConfig
8+
pure $ prefix config ++ "-" ++ baseName
9+
10+
wrap :: String -> Config String
11+
wrap name = do
12+
config <- getConfig
13+
pure $ openBracket config ++ name ++ closeBracket config
14+
15+
myConfig :: ConfigData
16+
myConfig = ConfigData
17+
{ prefix = "foobar"
18+
, openBracket = "<<"
19+
, closeBracket = ">>"
20+
}
21+
22+
run :: Config String
23+
run = makeName "hoge" >>= wrap
24+
25+
main :: IO ()
26+
main = do
27+
let ret = runConfig run myConfig
28+
putStrLn ret

haskell-reader/haskell-reader.cabal

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
cabal-version: 1.12
2+
3+
-- This file has been generated from package.yaml by hpack version 0.34.4.
4+
--
5+
-- see: https://github.com/sol/hpack
6+
7+
name: haskell-reader
8+
version: 0.1.0.0
9+
description: Please see the README on GitHub at <https://github.com/githubuser/haskell-reader#readme>
10+
homepage: https://github.com/githubuser/haskell-reader#readme
11+
bug-reports: https://github.com/githubuser/haskell-reader/issues
12+
author: Author name here
13+
maintainer: [email protected]
14+
copyright: 2021 Author name here
15+
license: BSD3
16+
license-file: LICENSE
17+
build-type: Simple
18+
extra-source-files:
19+
README.md
20+
ChangeLog.md
21+
22+
source-repository head
23+
type: git
24+
location: https://github.com/githubuser/haskell-reader
25+
26+
library
27+
exposed-modules:
28+
MyConfig
29+
other-modules:
30+
Paths_haskell_reader
31+
hs-source-dirs:
32+
src
33+
build-depends:
34+
base >=4.7 && <5
35+
default-language: Haskell2010
36+
37+
executable haskell-reader-exe
38+
main-is: Main.hs
39+
other-modules:
40+
Paths_haskell_reader
41+
hs-source-dirs:
42+
app
43+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
44+
build-depends:
45+
base >=4.7 && <5
46+
, haskell-reader
47+
default-language: Haskell2010
48+
49+
test-suite haskell-reader-test
50+
type: exitcode-stdio-1.0
51+
main-is: Spec.hs
52+
other-modules:
53+
Paths_haskell_reader
54+
hs-source-dirs:
55+
test
56+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
57+
build-depends:
58+
base >=4.7 && <5
59+
, haskell-reader
60+
default-language: Haskell2010

haskell-reader/package.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: haskell-reader
2+
version: 0.1.0.0
3+
github: "githubuser/haskell-reader"
4+
license: BSD3
5+
author: "Author name here"
6+
maintainer: "[email protected]"
7+
copyright: "2021 Author name here"
8+
9+
extra-source-files:
10+
- README.md
11+
- ChangeLog.md
12+
13+
# Metadata used when publishing your package
14+
# synopsis: Short description of your package
15+
# category: Web
16+
17+
# To avoid duplicated efforts in documentation and dealing with the
18+
# complications of embedding Haddock markup inside cabal files, it is
19+
# common to point users to the README.md file.
20+
description: Please see the README on GitHub at <https://github.com/githubuser/haskell-reader#readme>
21+
22+
dependencies:
23+
- base >= 4.7 && < 5
24+
25+
library:
26+
source-dirs: src
27+
28+
executables:
29+
haskell-reader-exe:
30+
main: Main.hs
31+
source-dirs: app
32+
ghc-options:
33+
- -threaded
34+
- -rtsopts
35+
- -with-rtsopts=-N
36+
dependencies:
37+
- haskell-reader
38+
39+
tests:
40+
haskell-reader-test:
41+
main: Spec.hs
42+
source-dirs: test
43+
ghc-options:
44+
- -threaded
45+
- -rtsopts
46+
- -with-rtsopts=-N
47+
dependencies:
48+
- haskell-reader

haskell-reader/src/MyConfig.hs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{-# LANGUAGE InstanceSigs, StrictData #-}
2+
module MyConfig
3+
( ConfigData(..)
4+
, Config
5+
, getConfig
6+
, runConfig
7+
) where
8+
9+
data ConfigData = ConfigData
10+
{ prefix :: String
11+
, openBracket :: String
12+
, closeBracket :: String
13+
}
14+
deriving (Show)
15+
16+
newtype Config a = Config (ConfigData -> a)
17+
18+
instance Functor Config where
19+
fmap :: (a -> b) -> Config a -> Config b
20+
fmap f (Config g) =
21+
Config (f . g)
22+
23+
instance Applicative Config where
24+
pure :: a -> Config a
25+
pure x =
26+
Config (const x)
27+
28+
(<*>) :: Config (a -> b) -> Config a -> Config b
29+
(<*>) (Config f) (Config g) =
30+
Config $ \config ->
31+
let
32+
f' = f config
33+
x = g config
34+
in
35+
f' x
36+
37+
instance Monad Config where
38+
(>>=) :: Config a -> (a -> Config b) -> Config b
39+
(>>=) (Config f) g =
40+
Config $ \config ->
41+
let
42+
x = f config
43+
Config y = g x
44+
in
45+
y config
46+
47+
getConfig :: Config ConfigData
48+
getConfig =
49+
Config id
50+
51+
runConfig :: Config a -> ConfigData -> a
52+
runConfig (Config f) config =
53+
f config

haskell-reader/stack.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This file was automatically generated by 'stack init'
2+
#
3+
# Some commonly used options have been documented as comments in this file.
4+
# For advanced use and comprehensive documentation of the format, please see:
5+
# https://docs.haskellstack.org/en/stable/yaml_configuration/
6+
7+
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8+
# A snapshot resolver dictates the compiler version and the set of packages
9+
# to be used for project dependencies. For example:
10+
#
11+
# resolver: lts-3.5
12+
# resolver: nightly-2015-09-21
13+
# resolver: ghc-7.10.2
14+
#
15+
# The location of a snapshot can be provided as a file or url. Stack assumes
16+
# a snapshot provided as a file might change, whereas a url resource does not.
17+
#
18+
# resolver: ./custom-snapshot.yaml
19+
# resolver: https://example.com/snapshots/2018-01-01.yaml
20+
resolver:
21+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
22+
23+
# User packages to be built.
24+
# Various formats can be used as shown in the example below.
25+
#
26+
# packages:
27+
# - some-directory
28+
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
29+
# subdirs:
30+
# - auto-update
31+
# - wai
32+
packages:
33+
- .
34+
# Dependency packages to be pulled from upstream that are not in the resolver.
35+
# These entries can reference officially published versions as well as
36+
# forks / in-progress versions pinned to a git hash. For example:
37+
#
38+
# extra-deps:
39+
# - acme-missiles-0.3
40+
# - git: https://github.com/commercialhaskell/stack.git
41+
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
42+
#
43+
# extra-deps: []
44+
45+
# Override default flag values for local packages and extra-deps
46+
# flags: {}
47+
48+
# Extra package databases containing global packages
49+
# extra-package-dbs: []
50+
51+
# Control whether we use the GHC we find on the path
52+
# system-ghc: true
53+
#
54+
# Require a specific version of stack, using version ranges
55+
# require-stack-version: -any # Default
56+
# require-stack-version: ">=2.7"
57+
#
58+
# Override the architecture used by stack, especially useful on Windows
59+
# arch: i386
60+
# arch: x86_64
61+
#
62+
# Extra directories used by stack for building
63+
# extra-include-dirs: [/path/to/dir]
64+
# extra-lib-dirs: [/path/to/dir]
65+
#
66+
# Allow a newer minor version of GHC than the snapshot specifies
67+
# compiler-check: newer-minor

haskell-reader/stack.yaml.lock

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was autogenerated by Stack.
2+
# You should not edit this file by hand.
3+
# For more information, please see the documentation at:
4+
# https://docs.haskellstack.org/en/stable/lock_files
5+
6+
packages: []
7+
snapshots:
8+
- completed:
9+
size: 585393
10+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
11+
sha256: c632012da648385b9fa3c29f4e0afd56ead299f1c5528ee789058be410e883c0
12+
original:
13+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml

haskell-reader/test/Spec.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main :: IO ()
2+
main = putStrLn "Test suite not yet implemented"
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {
8+
}
9+
}

0 commit comments

Comments
 (0)