about summary refs log tree commit diff
path: root/src/Xanthous/Messages.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xanthous/Messages.hs')
-rw-r--r--src/Xanthous/Messages.hs29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/Xanthous/Messages.hs b/src/Xanthous/Messages.hs
index b0dc0e4ae9d2..2b1b3da1e8c1 100644
--- a/src/Xanthous/Messages.hs
+++ b/src/Xanthous/Messages.hs
@@ -11,23 +11,25 @@ module Xanthous.Messages
   , render
   , lookup
   , message
+  , message_
   ) where
 --------------------------------------------------------------------------------
 import Xanthous.Prelude hiding (lookup)
 --------------------------------------------------------------------------------
-import Control.Monad.Random.Class (MonadRandom)
-import Data.Aeson (FromJSON, ToJSON, toJSON)
-import Data.Aeson.Generic.DerivingVia
-import Data.FileEmbed
-import Data.List.NonEmpty
-import Test.QuickCheck hiding (choose)
-import Test.QuickCheck.Arbitrary.Generic
-import Test.QuickCheck.Instances.UnorderedContainers ()
-import Text.Mustache
+import           Control.Monad.Random.Class (MonadRandom)
+import           Data.Aeson (FromJSON, ToJSON, toJSON)
+import qualified Data.Aeson as JSON
+import           Data.Aeson.Generic.DerivingVia
+import           Data.FileEmbed
+import           Data.List.NonEmpty
+import           Test.QuickCheck hiding (choose)
+import           Test.QuickCheck.Arbitrary.Generic
+import           Test.QuickCheck.Instances.UnorderedContainers ()
+import           Text.Mustache
 import qualified Data.Yaml as Yaml
 --------------------------------------------------------------------------------
-import Xanthous.Random
-import Xanthous.Orphans ()
+import           Xanthous.Random
+import           Xanthous.Orphans ()
 --------------------------------------------------------------------------------
 
 data Message = Single Template | Choice (NonEmpty Template)
@@ -98,3 +100,8 @@ message :: (MonadRandom m, ToJSON params) => [Text] -> params -> m Text
 message path params = maybe notFound (`render` params) $ messages ^? ix path
   where
     notFound = pure "Message not found"
+
+message_ :: (MonadRandom m) => [Text] -> m Text
+message_ path = maybe notFound (`render` JSON.object []) $ messages ^? ix path
+  where
+    notFound = pure "Message not found"