about summary refs log tree commit diff
path: root/src/Xanthous/Entities.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xanthous/Entities.hs')
-rw-r--r--src/Xanthous/Entities.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Xanthous/Entities.hs b/src/Xanthous/Entities.hs
index 93c4813cc483..ccd3ae42bfc3 100644
--- a/src/Xanthous/Entities.hs
+++ b/src/Xanthous/Entities.hs
@@ -10,6 +10,7 @@ module Xanthous.Entities
   , DrawCharacter(..)
   , DrawStyledCharacter(..)
   , DrawRawChar(..)
+  , DrawRawCharPriority(..)
   , Entity(..)
   , SomeEntity(..)
   , downcastEntity
@@ -97,6 +98,21 @@ instance
   ) => Draw (DrawRawChar rawField a) where
   draw (DrawRawChar e) = draw $ e ^. field @rawField . char
 
+newtype DrawRawCharPriority
+  (rawField :: Symbol)
+  (priority :: Nat)
+  (a :: Type)
+  = DrawRawCharPriority a
+
+instance
+  forall rawField priority a raw.
+  ( HasField rawField a a raw raw
+  , KnownNat priority
+  , HasChar raw EntityChar
+  ) => Draw (DrawRawCharPriority rawField priority a) where
+  draw (DrawRawCharPriority e) = draw $ e ^. field @rawField . char
+  drawPriority = const . fromIntegral $ natVal @priority Proxy
+
 --------------------------------------------------------------------------------
 
 data EntityChar = EntityChar