Skip to content

Commit fa02bdc

Browse files
author
dixiecko
committed
Create abstract EBook type.
1 parent 31ee7ec commit fa02bdc

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
File renamed without changes.
File renamed without changes.

src/Codec/EBook/Types.hs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-- Book Types definition
2+
3+
module Codec.EBook.Types (
4+
Book(..),
5+
BookItem(..),
6+
Metadata(..),
7+
emptyBook,
8+
addItem2Book
9+
)
10+
where
11+
12+
data Book = Book {
13+
bookID :: String,
14+
bookTitle :: String,
15+
bookAuthor :: String,
16+
bookLang :: String,
17+
bookItems :: [BookItem]
18+
} deriving (Show, Ord, Eq)
19+
20+
data BookItem = BookItem {
21+
itemFileName :: String,
22+
itemContent :: String,
23+
itemMediaType :: String,
24+
itemMetadata :: Maybe Metadata
25+
} deriving (Show, Ord, Eq)
26+
27+
data Metadata = ChapterMetadata {
28+
chapterTitle :: String
29+
} deriving (Show, Ord, Eq)
30+
31+
emptyBook :: Book
32+
emptyBook = Book "NO ID" "NO TITLE" "NO AUTHOR" "en" []
33+
34+
addItem2Book :: Book -> BookItem -> Book
35+
addItem2Book book item = book { bookItems = newItems }
36+
where
37+
newItems = (bookItems book) ++ [item]

0 commit comments

Comments
 (0)