on d82d607 help sign in
41 lines 1.0 kB history raw
1{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE RecordWildCards #-}
4{-# LANGUAGE TypeFamilies #-}
6-- | Rendering of Role annotation declarations.
8module Ormolu.Printer.Meat.Declaration.RoleAnnotation
9 ( p_roleAnnot
10 )
11where
13import CoAxiom
14import GHC
15import Ormolu.Printer.Combinators
16import Ormolu.Printer.Meat.Common
17import Ormolu.Utils
18import RdrName (RdrName (..))
19import SrcLoc (Located)
21p_roleAnnot :: RoleAnnotDecl GhcPs -> R ()
22p_roleAnnot = \case
23 RoleAnnotDecl NoExt l_name anns -> p_roleAnnot' l_name anns
24 XRoleAnnotDecl _ -> notImplemented "XRoleAnnotDecl"
26p_roleAnnot' :: Located RdrName -> [Located (Maybe Role)] -> R ()
27p_roleAnnot' l_name anns = line $ do
28 txt "type role"
29 breakpoint
30 inci $ do
31 p_rdrName l_name
32 breakpoint
33 let
34 p_role' = maybe (txt "_") p_role
35 inci $ velt' $ (located' p_role') <$> anns
37p_role :: Role -> R ()
38p_role = \case
39 Nominal -> txt "nominal"
40 Representational -> txt "representational"
41 Phantom -> txt "phantom"