Skip to content

Commit

Permalink
Chapter 5.3 - Package format
Browse files Browse the repository at this point in the history
  • Loading branch information
soupi committed May 8, 2022
1 parent 908e717 commit 8ca58ae
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 16 deletions.
29 changes: 29 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2021-2022, Gil Mizrahi
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# hs-blog

One day it will be a static blog generator.

[Read the book](https://lhbg-book.link).
8 changes: 8 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- app/Main.hs

module Main where

import qualified HsBlog

main :: IO ()
main = HsBlog.main
51 changes: 51 additions & 0 deletions hs-blog.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cabal-version: 2.4

name: hs-blog
version: 0.1.0.0
synopsis: A custom blog generator from markup files
description: This package provides a static blog generator
from a custom markup format to HTML.
It defines a parsing for this custom markup format
as well as an html pretty printer EDSL.

It is used as the example project in the online book
'Learn Haskell Blog Generator'. See the README for
more details.
homepage: https://github.com/soupi/learn-haskell-blog-generator
bug-reports: https://github.com/soupi/learn-haskell-blog-generator/issues
license: BSD-3-Clause
license-file: LICENSE.txt
author: Gil Mizrahi
maintainer: gilmi@posteo.net
category: Learning, Web
extra-doc-files:
README.md

common common-settings
default-language: Haskell2010
ghc-options:
-Wall

library
import: common-settings
hs-source-dirs: src
build-depends:
base
, directory
exposed-modules:
HsBlog
HsBlog.Convert
HsBlog.Html
HsBlog.Html.Internal
HsBlog.Markup
-- other-modules:

executable hs-blog-gen
import: common-settings
hs-source-dirs: app
main-is: Main.hs
build-depends:
base
, hs-blog
ghc-options:
-O
15 changes: 10 additions & 5 deletions Main.hs → src/HsBlog.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
-- Main.hs
module Main where
-- src/HsBlog.hs

import qualified Markup
import qualified Html
import Convert (convert)
module HsBlog
( main
, process
)
where

import qualified HsBlog.Markup as Markup
import qualified HsBlog.Html as Html
import HsBlog.Convert (convert)

import System.Directory (doesFileExist)
import System.Environment (getArgs)
Expand Down
8 changes: 4 additions & 4 deletions Convert.hs → src/HsBlog/Convert.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- Convert.hs
-- src/HsBlog/Convert.hs

module Convert where
module HsBlog.Convert where

import qualified Markup
import qualified Html
import qualified HsBlog.Markup as Markup
import qualified HsBlog.Html as Html

convert :: Html.Title -> Markup.Document -> Html.Html
convert title = Html.html_ title . foldMap convertStructure
Expand Down
6 changes: 3 additions & 3 deletions Html.hs → src/HsBlog/Html.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Html.hs
-- src/HsBlog/Html.hs

module Html
module HsBlog.Html
( Html
, Title
, Structure
Expand All @@ -14,4 +14,4 @@ module Html
)
where

import Html.Internal
import HsBlog.Html.Internal
4 changes: 2 additions & 2 deletions Html/Internal.hs → src/HsBlog/Html/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Html/Internal.hs
-- src/HsBlog/Html/Internal.hs

module Html.Internal where
module HsBlog.Html.Internal where

import Numeric.Natural

Expand Down
4 changes: 2 additions & 2 deletions Markup.hs → src/HsBlog/Markup.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Markup.hs
-- src/HsBlog/Markup.hs

module Markup
module HsBlog.Markup
( Document
, Structure(..)
, parse
Expand Down
4 changes: 4 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: lts-18.22

packages:
- .

0 comments on commit 8ca58ae

Please sign in to comment.