diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-06-27 16:48:37 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-06-27 16:48:37 +0200 |
| commit | 96dbf6846d8b4ffec0209f1c430335f679a83fb2 (patch) | |
| tree | 58c758f76f1d397654dd3458aa518d2a13310e78 /src | |
| parent | 92d57de84376ca059a0c0fb845d6c6e66707766a (diff) | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/Erebos/Conversation.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Erebos/Conversation.hs b/src/Erebos/Conversation.hs index 78774bd..e46f4a5 100644 --- a/src/Erebos/Conversation.hs +++ b/src/Erebos/Conversation.hs @@ -11,6 +11,7 @@ module Erebos.Conversation ( formatMessageFT, Conversation, + makeConversation, isSameConversation, directMessageConversation, chatroomConversation, @@ -39,6 +40,7 @@ import Data.Text (Text) import Data.Text qualified as T import Data.Time.Format import Data.Time.LocalTime +import Data.Typeable import Erebos.Chatroom import Erebos.Conversation.Class @@ -89,6 +91,12 @@ data Conversation = DirectMessageConversation DirectMessageThread | ChatroomConversation ChatroomState +makeConversation :: ConversationType conv msg => conv -> Conversation +makeConversation conv + | Just x <- cast conv = DirectMessageConversation x + | Just x <- cast conv = ChatroomConversation x + | otherwise = error "unhandled conversation type" + withConversation :: (forall conv msg. ConversationType conv msg => conv -> a) -> Conversation -> a withConversation f (DirectMessageConversation conv) = f conv withConversation f (ChatroomConversation conv) = f conv |