From a286a6c34242bbcc98f6c1f9e48fc2080b4ba9a8 Mon Sep 17 00:00:00 2001 From: Hiroki Tokunaga Date: Sun, 7 Apr 2024 23:46:25 +0900 Subject: [PATCH] Implement `Injectivity` (#867) * Implement `Injectivity` * Format --- .../Ast/Declaration/Family/Type/Injectivity.hs | 15 ++++++++++----- src/HIndent/Pretty.hs | 4 ---- src/HIndent/Pretty.hs-boot | 2 -- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/HIndent/Ast/Declaration/Family/Type/Injectivity.hs b/src/HIndent/Ast/Declaration/Family/Type/Injectivity.hs index 637d3d606..b9c27a418 100644 --- a/src/HIndent/Ast/Declaration/Family/Type/Injectivity.hs +++ b/src/HIndent/Ast/Declaration/Family/Type/Injectivity.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE RecordWildCards #-} + module HIndent.Ast.Declaration.Family.Type.Injectivity ( Injectivity , mkInjectivity @@ -6,16 +8,19 @@ module HIndent.Ast.Declaration.Family.Type.Injectivity import HIndent.Ast.NodeComments import qualified HIndent.GhcLibParserWrapper.GHC.Hs as GHC import {-# SOURCE #-} HIndent.Pretty +import HIndent.Pretty.Combinators import HIndent.Pretty.NodeComments -newtype Injectivity = - Injectivity (GHC.InjectivityAnn GHC.GhcPs) +data Injectivity = Injectivity + { from :: GHC.LIdP GHC.GhcPs + , to :: [GHC.LIdP GHC.GhcPs] + } instance CommentExtraction Injectivity where - nodeComments (Injectivity _) = NodeComments [] [] [] + nodeComments Injectivity {} = NodeComments [] [] [] instance Pretty Injectivity where - pretty' (Injectivity x) = pretty x + pretty' Injectivity {..} = spaced $ pretty from : string "->" : fmap pretty to mkInjectivity :: GHC.InjectivityAnn GHC.GhcPs -> Injectivity -mkInjectivity = Injectivity +mkInjectivity (GHC.InjectivityAnn _ from to) = Injectivity {..} diff --git a/src/HIndent/Pretty.hs b/src/HIndent/Pretty.hs index 40db999c4..6cd37d081 100644 --- a/src/HIndent/Pretty.hs +++ b/src/HIndent/Pretty.hs @@ -1232,10 +1232,6 @@ instance Pretty GHC.OverlapMode where instance Pretty GHC.StringLiteral where pretty' = output -instance Pretty (GHC.InjectivityAnn GHC.GhcPs) where - pretty' (GHC.InjectivityAnn _ from to) = - spaced $ pretty from : string "->" : fmap pretty to - instance Pretty (GHC.ArithSeqInfo GHC.GhcPs) where pretty' (GHC.From from) = brackets $ spaced [pretty from, string ".."] pretty' (GHC.FromThen from next) = diff --git a/src/HIndent/Pretty.hs-boot b/src/HIndent/Pretty.hs-boot index e39f47ac4..6308809f5 100644 --- a/src/HIndent/Pretty.hs-boot +++ b/src/HIndent/Pretty.hs-boot @@ -36,8 +36,6 @@ instance Pretty GHC.EpaComment instance Pretty (GHC.HsType GHC.GhcPs) -instance Pretty (GHC.InjectivityAnn GHC.GhcPs) - instance Pretty (GHC.FamEqn GHC.GhcPs