never executed always true always false
1 module HelVM.HelIO.Control.Message where
2
3 import qualified Data.DList as D
4
5 -- | Destructors
6 errorsToText :: Messages -> Text
7 errorsToText = unlines <$> D.toList
8
9 errorsToString :: Messages -> String
10 errorsToString = toString <$> errorsToText
11
12 -- | Constructors
13 stringToErrors :: String -> Messages
14 stringToErrors = D.singleton <$> toText
15
16 tupleListToMessage :: [MessageTuple] -> Message
17 tupleListToMessage xs = mconcat $ tupleToMessage <$> xs
18
19 tupleToMessage :: MessageTuple -> Message
20 tupleToMessage (prefix , showed) = " [" <> format prefix <> showed <> "]" where
21 format "" = ""
22 format _ = prefix <> " "
23
24 -- | Types
25 type MessageTuple = (Message , Message)
26
27 type Messages = D.DList Text
28
29 type Message = Text