aboutsummaryrefslogtreecommitdiff
path: root/entities/article.rkt
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2024-03-24 21:07:25 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2024-03-24 21:10:28 +0900
commit18a081d88ae031ba64215f1126e2ab756a692db2 (patch)
treedca8a69d81cdff136af0832e2c3306ade041cb4f /entities/article.rkt
parentdb4487272c42f73be62a63740ef1733dd4de3f52 (diff)
Add article entity.
Diffstat (limited to 'entities/article.rkt')
-rw-r--r--entities/article.rkt39
1 files changed, 39 insertions, 0 deletions
diff --git a/entities/article.rkt b/entities/article.rkt
new file mode 100644
index 0000000..14319d7
--- /dev/null
+++ b/entities/article.rkt
@@ -0,0 +1,39 @@
+#lang typed/racket
+
+(provide Article
+ make-article
+ article?
+ article-id
+ article-timestamp
+ article-hash
+ article-title
+ article-body
+
+ Article-With-Tags
+ make-article-with-tags
+ article-with-tags?
+ (rename-out [article-with-tags-tags article-tags])
+ article->article-with-tags)
+
+(struct article ([id : String]
+ [timestamp : date]
+ [hash : String]
+ [title : String]
+ [body : String])
+ #:type-name Article
+ #:constructor-name make-article
+ #:transparent)
+
+(struct article-with-tags article ([tags : (Listof String)])
+ #:type-name Article-With-Tags
+ #:constructor-name make-article-with-tags
+ #:transparent)
+
+(: article->article-with-tags (-> Article (Listof String) Article-With-Tags))
+(define (article->article-with-tags a tags)
+ (make-article-with-tags (article-id a)
+ (article-timestamp a)
+ (article-hash a)
+ (article-title a)
+ (article-body a)
+ tags))