aboutsummaryrefslogtreecommitdiffstats
path: root/src/Zettel.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2022-10-06 22:37:12 +0100
committerYann Herklotz <git@yannherklotz.com>2022-10-06 22:37:12 +0100
commitf19bc4e0cc33841d16f6d965f3b5df748aab163b (patch)
treeba19adf7757300d0c22b8cf26193817c147bf8c0 /src/Zettel.hs
parentb5caa24b94d1b713baf069d808bf5dce665ad7e2 (diff)
downloadzk-visual-f19bc4e0cc33841d16f6d965f3b5df748aab163b.tar.gz
zk-visual-f19bc4e0cc33841d16f6d965f3b5df748aab163b.zip
Add hs files
Diffstat (limited to 'src/Zettel.hs')
-rw-r--r--src/Zettel.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Zettel.hs b/src/Zettel.hs
new file mode 100644
index 0000000..5c07af9
--- /dev/null
+++ b/src/Zettel.hs
@@ -0,0 +1,38 @@
+module Zettel where
+
+newtype ZettelId = ZettelId
+ { -- | The ZettelId is just Text, however, it should also be possible to convert
+ -- it to a list of the ID split up into it's parts.
+ unZettelId :: Text
+ }
+ deriving (Show, Eq, Ord)
+
+instance IsString ZettelId where
+ fromString = ZettelId . fromString
+
+instance ToString ZettelId where
+ toString = toString . unZettelId
+
+instance Semigroup ZettelId where
+ ZettelId a <> ZettelId b = ZettelId $ a <> b
+
+instance Monoid ZettelId where
+ mempty = ZettelId mempty
+
+data Zettel = Zettel
+ { -- | The ID that is assigned to the Zettel.
+ zettelId :: !ZettelId,
+ -- | The title of the Zettel, which should also be present in the body, however,
+ -- this is useful to gather metadata about the Zettel.
+ zettelTitle :: !Text,
+ -- | The text body of the Zettel, which is stored as a Pandoc document to make it
+ -- easy to export to other documents.
+ zettelBody :: Pandoc
+ }
+ deriving (Show, Eq)
+
+instance Semigroup Zettel where
+ Zettel a b c <> Zettel _ _ c' = Zettel a b $ c <> c'
+
+instance Monoid Zettel where
+ mempty = Zettel mempty mempty mempty