1 {-# LANGUAGE TypeFamilies, OverloadedStrings #-} 2 module Model.Comment.Types 3 ( Comment(..) 4 , CommentRow(..) 5 , makeComment 6 ) where 7 8 import Data.Maybe (fromMaybe) 9 import qualified Data.Text as T 10 11 import Model.Container.Types 12 import Model.Kind 13 import Model.Time 14 import Model.Id.Types 15 import Model.Party.Types 16 import Model.Segment 17 import Model.Slot.Types 18 19 type instance IdType Comment = Int32 20 21 data Comment = Comment 22 { commentId :: Id Comment 23 , commentWho :: Account 24 , commentSlot :: Slot 25 , commentTime :: Timestamp 26 , commentText :: T.Text 27 , commentParents :: [Id Comment] 28 } 29 30 instance Kinded Comment where 31 kindOf _ = "comment" 32 33 data CommentRow = CommentRow 34 { commentRowId :: Id Comment 35 , commentRowWhoId :: Id Party 36 , commentRowSlotId :: SlotId 37 , commentRowTime :: Timestamp 38 , commentRowText :: T.Text 39 } 40 41 makeComment :: Id Comment -> Segment -> Timestamp -> T.Text -> [Maybe (Id Comment)] -> Account -> Container -> Comment 42 makeComment i s t x p w c = Comment i w (Slot c s) t x (map (fromMaybe (error "NULL comment thread")) p)