{-# language DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric #-}
{-# language InstanceSigs, ScopedTypeVariables, TypeApplications #-}
module Language.Python.Syntax.Punctuation where
import Control.Lens.Lens (Lens', lens)
import Data.Generics.Product.Typed (typed)
import GHC.Generics (Generic)
import Language.Python.Syntax.Ann
import Language.Python.Syntax.Whitespace
newtype Dot = MkDot [Whitespace]
deriving (Eq, Show)
instance HasTrailingWhitespace Dot where
trailingWhitespace =
lens (\(MkDot ws) -> ws) (\_ ws -> MkDot ws)
newtype Comma = MkComma [Whitespace]
deriving (Eq, Show, Generic)
instance HasTrailingWhitespace Comma where
trailingWhitespace =
lens (\(MkComma ws) -> ws) (\_ ws -> MkComma ws)
newtype Colon = MkColon [Whitespace]
deriving (Eq, Show, Generic)
instance HasTrailingWhitespace Colon where
trailingWhitespace =
lens (\(MkColon ws) -> ws) (\_ ws -> MkColon ws)
data Semicolon a = MkSemicolon (Ann a) [Whitespace]
deriving (Eq, Show, Functor, Foldable, Traversable, Generic)
instance HasAnn Semicolon where
annot :: forall a. Lens' (Semicolon a) (Ann a)
annot = typed @(Ann a)
instance HasTrailingWhitespace (Semicolon a) where
trailingWhitespace =
lens (\(MkSemicolon _ ws) -> ws) (\(MkSemicolon a _) ws -> MkSemicolon a ws)
newtype Equals
= MkEquals [Whitespace]
deriving (Eq, Show)
instance HasTrailingWhitespace Equals where
trailingWhitespace =
lens (\(MkEquals ws) -> ws) (\_ ws -> MkEquals ws)
newtype At
= MkAt [Whitespace]
deriving (Eq, Show)
instance HasTrailingWhitespace At where
trailingWhitespace =
lens (\(MkAt ws) -> ws) (\_ ws -> MkAt ws)