Skip to content

Commit 8ca58ae

Browse files
committed
Chapter 5.3 - Package format
1 parent 908e717 commit 8ca58ae

File tree

10 files changed

+118
-16
lines changed

10 files changed

+118
-16
lines changed

LICENSE.txt

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

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# hs-blog
2+
3+
One day it will be a static blog generator.
4+
5+
[Read the book](https://lhbg-book.link).

app/Main.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- app/Main.hs
2+
3+
module Main where
4+
5+
import qualified HsBlog
6+
7+
main :: IO ()
8+
main = HsBlog.main

hs-blog.cabal

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
cabal-version: 2.4
2+
3+
name: hs-blog
4+
version: 0.1.0.0
5+
synopsis: A custom blog generator from markup files
6+
description: This package provides a static blog generator
7+
from a custom markup format to HTML.
8+
It defines a parsing for this custom markup format
9+
as well as an html pretty printer EDSL.
10+
11+
It is used as the example project in the online book
12+
'Learn Haskell Blog Generator'. See the README for
13+
more details.
14+
homepage: https://github.com/soupi/learn-haskell-blog-generator
15+
bug-reports: https://github.com/soupi/learn-haskell-blog-generator/issues
16+
license: BSD-3-Clause
17+
license-file: LICENSE.txt
18+
author: Gil Mizrahi
19+
maintainer: [email protected]
20+
category: Learning, Web
21+
extra-doc-files:
22+
README.md
23+
24+
common common-settings
25+
default-language: Haskell2010
26+
ghc-options:
27+
-Wall
28+
29+
library
30+
import: common-settings
31+
hs-source-dirs: src
32+
build-depends:
33+
base
34+
, directory
35+
exposed-modules:
36+
HsBlog
37+
HsBlog.Convert
38+
HsBlog.Html
39+
HsBlog.Html.Internal
40+
HsBlog.Markup
41+
-- other-modules:
42+
43+
executable hs-blog-gen
44+
import: common-settings
45+
hs-source-dirs: app
46+
main-is: Main.hs
47+
build-depends:
48+
base
49+
, hs-blog
50+
ghc-options:
51+
-O

Main.hs renamed to src/HsBlog.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
-- Main.hs
2-
module Main where
1+
-- src/HsBlog.hs
32

4-
import qualified Markup
5-
import qualified Html
6-
import Convert (convert)
3+
module HsBlog
4+
( main
5+
, process
6+
)
7+
where
8+
9+
import qualified HsBlog.Markup as Markup
10+
import qualified HsBlog.Html as Html
11+
import HsBlog.Convert (convert)
712

813
import System.Directory (doesFileExist)
914
import System.Environment (getArgs)

Convert.hs renamed to src/HsBlog/Convert.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
-- Convert.hs
1+
-- src/HsBlog/Convert.hs
22

3-
module Convert where
3+
module HsBlog.Convert where
44

5-
import qualified Markup
6-
import qualified Html
5+
import qualified HsBlog.Markup as Markup
6+
import qualified HsBlog.Html as Html
77

88
convert :: Html.Title -> Markup.Document -> Html.Html
99
convert title = Html.html_ title . foldMap convertStructure

Html.hs renamed to src/HsBlog/Html.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-- Html.hs
1+
-- src/HsBlog/Html.hs
22

3-
module Html
3+
module HsBlog.Html
44
( Html
55
, Title
66
, Structure
@@ -14,4 +14,4 @@ module Html
1414
)
1515
where
1616

17-
import Html.Internal
17+
import HsBlog.Html.Internal

Html/Internal.hs renamed to src/HsBlog/Html/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-- Html/Internal.hs
1+
-- src/HsBlog/Html/Internal.hs
22

3-
module Html.Internal where
3+
module HsBlog.Html.Internal where
44

55
import Numeric.Natural
66

Markup.hs renamed to src/HsBlog/Markup.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-- Markup.hs
1+
-- src/HsBlog/Markup.hs
22

3-
module Markup
3+
module HsBlog.Markup
44
( Document
55
, Structure(..)
66
, parse

stack.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolver: lts-18.22
2+
3+
packages:
4+
- .

0 commit comments

Comments
 (0)