From 30d83d7c828f7bf5ed285f71e5b4a7bf095002b5 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 13 Jun 2021 23:02:11 -0400 Subject: feat(xanthous): Add a method to get the name for a type of entity I didn't end up using this directly for the thing I was doing, but it still seems generally useful enough that I'm keeping it around for now Change-Id: I05c8902d75845f2230ec2373a9677d61cfaafafd Reviewed-on: https://cl.tvl.fyi/c/depot/+/3206 Reviewed-by: grfn Tested-by: BuildkiteCI --- users/grfn/xanthous/src/Xanthous/Game/State.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'users/grfn/xanthous/src') diff --git a/users/grfn/xanthous/src/Xanthous/Game/State.hs b/users/grfn/xanthous/src/Xanthous/Game/State.hs index cdaf23edcd48..6f51683d14fe 100644 --- a/users/grfn/xanthous/src/Xanthous/Game/State.hs +++ b/users/grfn/xanthous/src/Xanthous/Game/State.hs @@ -56,6 +56,8 @@ module Xanthous.Game.State , downcastEntity , _SomeEntity , entityIs + , entityTypeName + -- ** Vias , Color(..) , DrawNothing(..) @@ -394,6 +396,10 @@ entityIs = isJust . downcastEntity @a _SomeEntity :: forall a. (Entity a, Typeable a) => Prism' SomeEntity a _SomeEntity = prism' SomeEntity downcastEntity +-- | Get the name of the type of 'SomeEntity' as a string +entityTypeName :: SomeEntity -> Text +entityTypeName (SomeEntity e) = pack . tyConName . typeRepTyCon $ typeOf e + newtype DeriveEntity (blocksVision :: Bool) (description :: Symbol) -- cgit 1.4.1