-- | Supporting definitions for COMPLEX literals.

module Language.Fortran.AST.Literal.Complex where

import Language.Fortran.AST.Common ( Name )
import Language.Fortran.AST.Literal ( KindParam )
import Language.Fortran.AST.Literal.Real
import Language.Fortran.Util.Position ( SrcSpan, Spanned )

import GHC.Generics                   ( Generic )
import Data.Data                      ( Data, Typeable )
import Control.DeepSeq                ( NFData )
import Text.PrettyPrint.GenericPretty ( Out )
import Language.Fortran.Util.FirstParameter  ( FirstParameter )
import Language.Fortran.Util.SecondParameter ( SecondParameter )
import Language.Fortran.AST.Annotated ( Annotated )

-- | A COMPLEX literal, composed of a real part and an imaginary part.
--
-- Fortran has lots of rules on how COMPLEX literals are defined and used in
-- various contexts. To support all that, we define the syntactic structure
-- 'ComplexLit' to wrap all the parsing rules. Then during a analysis pass, you
-- may (attempt to) convert these into a more regular type, like a Haskell
-- @(Double, Double)@ tuple.
data ComplexLit a = ComplexLit
  { forall a. ComplexLit a -> a
complexLitAnno     :: a
  , forall a. ComplexLit a -> SrcSpan
complexLitPos      :: SrcSpan
  , forall a. ComplexLit a -> ComplexPart a
complexLitRealPart :: ComplexPart a
  , forall a. ComplexLit a -> ComplexPart a
complexLitImagPart :: ComplexPart a
  } deriving stock    (ComplexLit a -> ComplexLit a -> Bool
forall a. Eq a => ComplexLit a -> ComplexLit a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComplexLit a -> ComplexLit a -> Bool
$c/= :: forall a. Eq a => ComplexLit a -> ComplexLit a -> Bool
== :: ComplexLit a -> ComplexLit a -> Bool
$c== :: forall a. Eq a => ComplexLit a -> ComplexLit a -> Bool
Eq, Int -> ComplexLit a -> ShowS
forall a. Show a => Int -> ComplexLit a -> ShowS
forall a. Show a => [ComplexLit a] -> ShowS
forall a. Show a => ComplexLit a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComplexLit a] -> ShowS
$cshowList :: forall a. Show a => [ComplexLit a] -> ShowS
show :: ComplexLit a -> String
$cshow :: forall a. Show a => ComplexLit a -> String
showsPrec :: Int -> ComplexLit a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> ComplexLit a -> ShowS
Show, ComplexLit a -> DataType
ComplexLit a -> Constr
forall {a}. Data a => Typeable (ComplexLit a)
forall a. Data a => ComplexLit a -> DataType
forall a. Data a => ComplexLit a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> ComplexLit a -> ComplexLit a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ComplexLit a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> ComplexLit a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexLit a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexLit a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexLit a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexLit a -> c (ComplexLit a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexLit a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ComplexLit a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexLit a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexLit a -> c (ComplexLit a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexLit a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> ComplexLit a -> m (ComplexLit a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComplexLit a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ComplexLit a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ComplexLit a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> ComplexLit a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexLit a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexLit a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexLit a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexLit a -> r
gmapT :: (forall b. Data b => b -> b) -> ComplexLit a -> ComplexLit a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> ComplexLit a -> ComplexLit a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ComplexLit a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ComplexLit a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexLit a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexLit a))
dataTypeOf :: ComplexLit a -> DataType
$cdataTypeOf :: forall a. Data a => ComplexLit a -> DataType
toConstr :: ComplexLit a -> Constr
$ctoConstr :: forall a. Data a => ComplexLit a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexLit a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexLit a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexLit a -> c (ComplexLit a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexLit a -> c (ComplexLit a)
Data, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (ComplexLit a) x -> ComplexLit a
forall a x. ComplexLit a -> Rep (ComplexLit a) x
$cto :: forall a x. Rep (ComplexLit a) x -> ComplexLit a
$cfrom :: forall a x. ComplexLit a -> Rep (ComplexLit a) x
Generic, forall a b. a -> ComplexLit b -> ComplexLit a
forall a b. (a -> b) -> ComplexLit a -> ComplexLit b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ComplexLit b -> ComplexLit a
$c<$ :: forall a b. a -> ComplexLit b -> ComplexLit a
fmap :: forall a b. (a -> b) -> ComplexLit a -> ComplexLit b
$cfmap :: forall a b. (a -> b) -> ComplexLit a -> ComplexLit b
Functor)
    deriving anyclass (forall a. NFData a => ComplexLit a -> ()
forall a. (a -> ()) -> NFData a
rnf :: ComplexLit a -> ()
$crnf :: forall a. NFData a => ComplexLit a -> ()
NFData, forall a. Out a => Int -> ComplexLit a -> Doc
forall a. Out a => [ComplexLit a] -> Doc
forall a. Out a => ComplexLit a -> Doc
forall a. (Int -> a -> Doc) -> (a -> Doc) -> ([a] -> Doc) -> Out a
docList :: [ComplexLit a] -> Doc
$cdocList :: forall a. Out a => [ComplexLit a] -> Doc
doc :: ComplexLit a -> Doc
$cdoc :: forall a. Out a => ComplexLit a -> Doc
docPrec :: Int -> ComplexLit a -> Doc
$cdocPrec :: forall a. Out a => Int -> ComplexLit a -> Doc
Out)

instance FirstParameter  (ComplexLit a) a
instance Annotated       ComplexLit
instance SecondParameter (ComplexLit a) SrcSpan
instance Spanned         (ComplexLit a)

-- | A part (either real or imaginary) of a complex literal.
--
-- Since Fortran 2003, complex literal parts support named constants, which must
-- be resolved in context at compile time (R422, R423).
--
-- Some compilers also allow constant expressions for the parts, and must
-- evaluate at compile time. That's not allowed in any standard. Apparently,
-- gfortran and ifort don't allow it, while nvfortran does. See:
-- https://fortran-lang.discourse.group/t/complex-constants-and-variables/2909/3
--
-- We specifically avoid supporting that by defining complex parts without being
-- mutually recursive with 'Expression'.
data ComplexPart a
  = ComplexPartReal   a SrcSpan RealLit (Maybe (KindParam a)) -- ^ signed real lit
  | ComplexPartInt    a SrcSpan String  (Maybe (KindParam a)) -- ^ signed int  lit
  | ComplexPartNamed  a SrcSpan Name                          -- ^ named constant
    deriving stock    (ComplexPart a -> ComplexPart a -> Bool
forall a. Eq a => ComplexPart a -> ComplexPart a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComplexPart a -> ComplexPart a -> Bool
$c/= :: forall a. Eq a => ComplexPart a -> ComplexPart a -> Bool
== :: ComplexPart a -> ComplexPart a -> Bool
$c== :: forall a. Eq a => ComplexPart a -> ComplexPart a -> Bool
Eq, Int -> ComplexPart a -> ShowS
forall a. Show a => Int -> ComplexPart a -> ShowS
forall a. Show a => [ComplexPart a] -> ShowS
forall a. Show a => ComplexPart a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComplexPart a] -> ShowS
$cshowList :: forall a. Show a => [ComplexPart a] -> ShowS
show :: ComplexPart a -> String
$cshow :: forall a. Show a => ComplexPart a -> String
showsPrec :: Int -> ComplexPart a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> ComplexPart a -> ShowS
Show, ComplexPart a -> DataType
ComplexPart a -> Constr
forall {a}. Data a => Typeable (ComplexPart a)
forall a. Data a => ComplexPart a -> DataType
forall a. Data a => ComplexPart a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> ComplexPart a -> ComplexPart a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ComplexPart a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> ComplexPart a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexPart a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexPart a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexPart a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexPart a -> c (ComplexPart a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexPart a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ComplexPart a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexPart a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexPart a -> c (ComplexPart a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexPart a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> ComplexPart a -> m (ComplexPart a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComplexPart a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ComplexPart a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ComplexPart a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> ComplexPart a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexPart a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexPart a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexPart a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ComplexPart a -> r
gmapT :: (forall b. Data b => b -> b) -> ComplexPart a -> ComplexPart a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> ComplexPart a -> ComplexPart a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ComplexPart a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ComplexPart a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexPart a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ComplexPart a))
dataTypeOf :: ComplexPart a -> DataType
$cdataTypeOf :: forall a. Data a => ComplexPart a -> DataType
toConstr :: ComplexPart a -> Constr
$ctoConstr :: forall a. Data a => ComplexPart a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexPart a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ComplexPart a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexPart a -> c (ComplexPart a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComplexPart a -> c (ComplexPart a)
Data, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (ComplexPart a) x -> ComplexPart a
forall a x. ComplexPart a -> Rep (ComplexPart a) x
$cto :: forall a x. Rep (ComplexPart a) x -> ComplexPart a
$cfrom :: forall a x. ComplexPart a -> Rep (ComplexPart a) x
Generic, forall a b. a -> ComplexPart b -> ComplexPart a
forall a b. (a -> b) -> ComplexPart a -> ComplexPart b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ComplexPart b -> ComplexPart a
$c<$ :: forall a b. a -> ComplexPart b -> ComplexPart a
fmap :: forall a b. (a -> b) -> ComplexPart a -> ComplexPart b
$cfmap :: forall a b. (a -> b) -> ComplexPart a -> ComplexPart b
Functor)
    deriving anyclass (forall a. NFData a => ComplexPart a -> ()
forall a. (a -> ()) -> NFData a
rnf :: ComplexPart a -> ()
$crnf :: forall a. NFData a => ComplexPart a -> ()
NFData, forall a. Out a => Int -> ComplexPart a -> Doc
forall a. Out a => [ComplexPart a] -> Doc
forall a. Out a => ComplexPart a -> Doc
forall a. (Int -> a -> Doc) -> (a -> Doc) -> ([a] -> Doc) -> Out a
docList :: [ComplexPart a] -> Doc
$cdocList :: forall a. Out a => [ComplexPart a] -> Doc
doc :: ComplexPart a -> Doc
$cdoc :: forall a. Out a => ComplexPart a -> Doc
docPrec :: Int -> ComplexPart a -> Doc
$cdocPrec :: forall a. Out a => Int -> ComplexPart a -> Doc
Out)

instance FirstParameter  (ComplexPart a) a
instance Annotated       ComplexPart
instance SecondParameter (ComplexPart a) SrcSpan
instance Spanned         (ComplexPart a)

-- | Is the given COMPLEX literal "pure", i.e. does it have no named constant
--   components?
complexLitIsPure :: ComplexLit a -> Bool
complexLitIsPure :: forall a. ComplexLit a -> Bool
complexLitIsPure ComplexLit a
c =
    forall {a}. ComplexPart a -> Bool
check (forall a. ComplexLit a -> ComplexPart a
complexLitRealPart ComplexLit a
c) Bool -> Bool -> Bool
&& forall {a}. ComplexPart a -> Bool
check (forall a. ComplexLit a -> ComplexPart a
complexLitImagPart ComplexLit a
c)
  where check :: ComplexPart a -> Bool
check = \case ComplexPartNamed{} -> Bool
False
                      ComplexPart a
_                  -> Bool
True