From 3f901966abf51891b97a6170cae2bcb77383edf3 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Mon, 3 Jun 2024 13:35:33 +0300 Subject: [PATCH] wip --- fixme-new/lib/Fixme/Run.hs | 8 +++----- fixme-new/lib/Fixme/Types.hs | 9 +++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fixme-new/lib/Fixme/Run.hs b/fixme-new/lib/Fixme/Run.hs index 3a6ed335..7556b143 100644 --- a/fixme-new/lib/Fixme/Run.hs +++ b/fixme-new/lib/Fixme/Run.hs @@ -42,8 +42,6 @@ import Control.Monad.Trans.Maybe import Streaming.Prelude qualified as S --- FIXME: move-to-suckless-conf -deriving stock instance Ord (Syntax C) {- HLINT ignore "Functor law" -} @@ -199,7 +197,7 @@ list_ tpl a = do Just (Simple (SimpleTemplate simple)) -> do for_ fixmies $ \(FixmeThin attr) -> do - let subst = [ (mksym k, mkstr @C v) | (k,v) <- HM.toList attr ] + let subst = [ (mkId k, mkstr @C v) | (k,v) <- HM.toList attr ] let what = render (SimpleTemplate (inject subst simple)) & fromRight "render error" @@ -248,9 +246,9 @@ cat_ metaOnly hash = do let origLen = maybe 0 fromIntegral fixmeEnd - maybe 0 fromIntegral fixmeStart & max 1 let lno = max 1 $ origLen + after + before - let dict = [ (mksym k, mkstr @C v) | (k,v) <- HM.toList fixmeAttr ] + let dict = [ (mkId k, mkstr @C v) | (k,v) <- HM.toList fixmeAttr ] <> - [ (mksym "before", mkstr @C (FixmeAttrVal $ Text.pack $ show bbefore)) + [ (mkId (FixmeAttrName "before"), mkstr @C (FixmeAttrVal $ Text.pack $ show bbefore)) ] debug (pretty cmd) diff --git a/fixme-new/lib/Fixme/Types.hs b/fixme-new/lib/Fixme/Types.hs index cd093beb..37f6fad6 100644 --- a/fixme-new/lib/Fixme/Types.hs +++ b/fixme-new/lib/Fixme/Types.hs @@ -28,6 +28,8 @@ import Data.Map qualified as Map import System.FilePath import Text.InterpolatedString.Perl6 (qc) +-- FIXME: move-to-suckless-conf +deriving stock instance Ord (Syntax C) pattern StringLike :: forall {c} . String -> Syntax c pattern StringLike e <- (stringLike -> Just e) @@ -309,8 +311,11 @@ commentKey fp = type ContextShit c = (Data c, Data (Context c), IsContext c, Data (Syntax c)) -mksym :: FixmeAttrName -> Id -mksym (k :: FixmeAttrName) = Id ("$" <> coerce k) +class MkId a where + mkId :: a -> Id + +instance MkId FixmeAttrName where + mkId (k :: FixmeAttrName) = Id ("$" <> coerce k) mkstr :: forall c . (IsContext c) => FixmeAttrVal -> Syntax c mkstr (s :: FixmeAttrVal) = Literal (noContext @c) (LitStr (coerce s))