-- Module      : Verismith.Verilog2005.PrettyPrinter
-- Description : Pretty printer for the Verilog 2005 AST.
-- Copyright   : (c) 2023 Quentin Corradi
-- License     : GPL-3
-- Maintainer  : q [dot] corradi22 [at] imperial [dot] ac [dot] uk
-- Stability   : experimental
-- Portability : POSIX
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE RankNTypes #-}

module Verismith.Verilog2005.PrettyPrinter
  ( genSource,
    LocalCompDir (..),
    lcdDefault,
    lcdTimescale,
    lcdCell,
    lcdPull,
    lcdDefNetType,
    PrintingOpts (..)
  )
where

import Control.Lens.TH
import Data.Bifunctor (first)
import Data.Functor.Compose
import Data.Functor.Identity
import Control.Monad.Reader
import qualified Data.ByteString as B
import Data.ByteString.Internal
import qualified Data.ByteString.Lazy as LB
import Data.Foldable
import Control.Applicative (liftA2)
import Data.List (intercalate)
import Data.List.NonEmpty (NonEmpty (..), (<|))
import qualified Data.List.NonEmpty as NE
import Data.Maybe (fromJust, fromMaybe)
import Data.String
import qualified Data.Vector.Unboxed as V
import Verismith.Utils hiding (comma)
import Verismith.Verilog2005.Lexer
import Verismith.Verilog2005.AST
import Verismith.Verilog2005.LibPretty
import Verismith.Verilog2005.Utils

-- | All locally applicable properties controlled by compiler directives
data LocalCompDir = LocalCompDir
  { LocalCompDir -> Maybe (Int, Int)
_lcdTimescale :: !(Maybe (Int, Int)),
    LocalCompDir -> Bool
_lcdCell :: !Bool,
    LocalCompDir -> Maybe Bool
_lcdPull :: !(Maybe Bool),
    LocalCompDir -> Maybe NetType
_lcdDefNetType :: !(Maybe NetType)
  }

$(makeLenses ''LocalCompDir)

lcdDefault :: LocalCompDir
lcdDefault :: LocalCompDir
lcdDefault = Maybe (Int, Int)
-> Bool -> Maybe Bool -> Maybe NetType -> LocalCompDir
LocalCompDir Maybe (Int, Int)
forall a. Maybe a
Nothing Bool
False Maybe Bool
forall a. Maybe a
Nothing (Maybe NetType -> LocalCompDir) -> Maybe NetType -> LocalCompDir
forall a b. (a -> b) -> a -> b
$ NetType -> Maybe NetType
forall a. a -> Maybe a
Just NetType
NTWire

-- | Pretty-printer options
data PrintingOpts = PrintingOpts
  { PrintingOpts -> Bool
_poEscapedSpace :: !Bool,
    PrintingOpts -> Bool
_poTableSpace :: !Bool,
    PrintingOpts -> Bool
_poEdgeControlZ_X :: !Bool
  }

type Print = Reader PrintingOpts Doc

-- | Generates a string from a line length limit and a Verilog AST
genSource :: Maybe Word -> PrintingOpts -> Verilog2005 -> LB.ByteString
genSource :: Maybe Word -> PrintingOpts -> Verilog2005 -> ByteString
genSource Maybe Word
mw PrintingOpts
opts Verilog2005
ast = Maybe Word -> Doc' () -> ByteString
forall w. Maybe Word -> Doc' w -> ByteString
layout Maybe Word
mw (Doc' () -> ByteString) -> Doc' () -> ByteString
forall a b. (a -> b) -> a -> b
$ Reader PrintingOpts (Doc' ()) -> PrintingOpts -> Doc' ()
forall r a. Reader r a -> r -> a
runReader (Verilog2005 -> Reader PrintingOpts (Doc' ())
prettyVerilog2005 Verilog2005
ast) PrintingOpts
opts

-- | Comma separated concatenation
(<.>) :: Doc -> Doc -> Doc
<.> :: Doc' () -> Doc' () -> Doc' ()
(<.>) Doc' ()
a Doc' ()
b = Doc' ()
a Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
b

-- | [] {} ()
brk :: Doc -> Doc
brk :: Doc' () -> Doc' ()
brk = Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
encl Doc' ()
forall w. Doc' w
lbracket Doc' ()
forall w. Doc' w
rbracket

brc :: Doc -> Doc
brc :: Doc' () -> Doc' ()
brc = Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
encl Doc' ()
forall w. Doc' w
lbrace Doc' ()
forall w. Doc' w
rbrace

par :: Doc -> Doc
par :: Doc' () -> Doc' ()
par = Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
encl Doc' ()
forall w. Doc' w
lparen Doc' ()
forall w. Doc' w
rparen

gpar :: Doc -> Doc
gpar :: Doc' () -> Doc' ()
gpar = Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par

-- | Print only if boolean is false
piff :: Doc -> Bool -> Doc
piff :: Doc' () -> Bool -> Doc' ()
piff Doc' ()
d Bool
c = if Bool
c then Doc' ()
forall a. Monoid a => a
mempty else Doc' ()
d

-- | Print only if boolean is true
pift :: Doc -> Bool -> Doc
pift :: Doc' () -> Bool -> Doc' ()
pift Doc' ()
d Bool
c = if Bool
c then Doc' ()
d else Doc' ()
forall a. Monoid a => a
mempty

-- | Print maybe
pm :: (x -> Print) -> Maybe x -> Print
pm :: forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm = Reader PrintingOpts (Doc' ())
-> (x -> Reader PrintingOpts (Doc' ()))
-> Maybe x
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reader PrintingOpts (Doc' ())
 -> (x -> Reader PrintingOpts (Doc' ()))
 -> Maybe x
 -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> (x -> Reader PrintingOpts (Doc' ()))
-> Maybe x
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty

-- | Print Foldable with stuff arround when not empty
pf :: Foldable f => (Doc -> Doc -> Doc) -> Doc -> Doc -> (a -> Print) -> f a -> Print
pf :: forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pf Doc' () -> Doc' () -> Doc' ()
g Doc' ()
l Doc' ()
r a -> Reader PrintingOpts (Doc' ())
f = Reader PrintingOpts (Doc' ())
-> (NonEmpty a -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (NonEmpty a -> b) -> [a] -> b
nonEmpty (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Doc' ()
d -> Doc' ()
l Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
r) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> (a -> b -> b) -> NonEmpty a -> b
foldrMap1 a -> Reader PrintingOpts (Doc' ())
f ((Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
g (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> a
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Reader PrintingOpts (Doc' ())
f)) ([a] -> Reader PrintingOpts (Doc' ()))
-> (f a -> [a]) -> f a -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> [a]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList

-- | Print Foldable
pl :: Foldable f => (Doc -> Doc -> Doc) -> (a -> Print) -> f a -> Print
pl :: forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
g a -> Reader PrintingOpts (Doc' ())
f = Reader PrintingOpts (Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (a -> b) -> (a -> b -> b) -> [a] -> b
foldrMap1' (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) a -> Reader PrintingOpts (Doc' ())
f ((Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
g (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> a
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Reader PrintingOpts (Doc' ())
f) ([a] -> Reader PrintingOpts (Doc' ()))
-> (f a -> [a]) -> f a -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> [a]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList

-- | Regroup and prettyprint
prettyregroup ::
  (Doc -> Doc -> Doc) ->
  (y -> Print) ->
  (x -> y) ->
  (x -> y -> Maybe y) ->
  NonEmpty x ->
  Print
prettyregroup :: forall y x.
(Doc' () -> Doc' () -> Doc' ())
-> (y -> Reader PrintingOpts (Doc' ()))
-> (x -> y)
-> (x -> y -> Maybe y)
-> NonEmpty x
-> Reader PrintingOpts (Doc' ())
prettyregroup Doc' () -> Doc' () -> Doc' ()
g y -> Reader PrintingOpts (Doc' ())
p x -> y
mk x -> y -> Maybe y
add = (y -> Reader PrintingOpts (Doc' ()))
-> (y
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> NonEmpty y
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> (a -> b -> b) -> NonEmpty a -> b
foldrMap1 y -> Reader PrintingOpts (Doc' ())
p ((Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
g (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (y -> Reader PrintingOpts (Doc' ()))
-> y
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. y -> Reader PrintingOpts (Doc' ())
p) (NonEmpty y -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty x -> NonEmpty y)
-> NonEmpty x
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x -> y) -> (x -> y -> Maybe y) -> NonEmpty x -> NonEmpty y
forall x y.
(x -> y) -> (x -> y -> Maybe y) -> NonEmpty x -> NonEmpty y
regroup x -> y
mk x -> y -> Maybe y
add

-- | The core difficulty of this pretty printer:
-- | Identifier can be escaped, escaped identifiers require a space or newline after them
-- | but I want to avoid double [spaces/line breaks] and spaces at the end of a line
-- | And this problem creeps in every AST node with possible identifier printed at the end
-- | like expressions
-- | So a prettyprinter that takes an AST node of type `a` has this type
-- | The second element of the result pair is the type of space that follows the first element
-- | unless what is next is a space or a newline, in which case it can be ignored and replaced
type PrettyIdent a = a -> Reader PrintingOpts (Doc, Doc)

-- | The `pure/return` of prettyIdent
mkid :: PrettyIdent Doc
mkid :: PrettyIdent (Doc' ())
mkid = (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> (Doc' () -> (Doc' (), Doc' ())) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' () -> (Doc' (), Doc' ()))
-> Doc' () -> Doc' () -> (Doc' (), Doc' ())
forall a b c. (a -> b -> c) -> b -> a -> c
flip (,) Doc' ()
forall w. Enum w => Doc' w
softline

-- | Evaluates a PrettyIdent and collapse the last character
padj :: PrettyIdent a -> a -> Print
padj :: forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent a
p = ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc' () -> Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> Doc' ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
(<>)) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent a
p

-- | Applies a function to the stuff before the last character
fpadj :: (Doc -> Doc) -> PrettyIdent a -> a -> Print
fpadj :: forall a.
(Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
fpadj Doc' () -> Doc' ()
f PrettyIdent a
p a
x = (Doc' () -> Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> Doc' ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
(<>) ((Doc' (), Doc' ()) -> Doc' ())
-> ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> (Doc' (), Doc' ())
-> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
f ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent a
p a
x

gpadj :: PrettyIdent a -> a -> Print
gpadj :: forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj = (Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall a.
(Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
fpadj Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group

ngpadj :: PrettyIdent a -> a -> Print
ngpadj :: forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj = (Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall a.
(Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
fpadj Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng

-- | Just inserts a group before the last space of a PrettyIdent
-- | Useful to separate the break priority of the inside and outside space
mkg :: PrettyIdent x -> PrettyIdent x
mkg :: forall x. PrettyIdent x -> PrettyIdent x
mkg PrettyIdent x
f = ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> PrettyIdent x -> PrettyIdent x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent x
f

-- | In this version the group asks for raising the indentation level
mkng :: PrettyIdent x -> PrettyIdent x
mkng :: forall x. PrettyIdent x -> PrettyIdent x
mkng PrettyIdent x
f = ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> PrettyIdent x -> PrettyIdent x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent x
f

-- | Print a comma separated list, haskell style: `a, b, c` or
-- | ```
-- | a
-- | , b
-- | , c
-- | ```
csl :: Foldable f => Doc -> Doc -> (a -> Print) -> f a -> Print
csl :: forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
csl = (Doc' () -> Doc' () -> Doc' ())
-> Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pf ((Doc' () -> Doc' () -> Doc' ())
 -> Doc' ()
 -> Doc' ()
 -> (a -> Reader PrintingOpts (Doc' ()))
 -> f a
 -> Reader PrintingOpts (Doc' ()))
-> (Doc' () -> Doc' () -> Doc' ())
-> Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ \Doc' ()
a Doc' ()
b -> Doc' ()
a Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
b

csl1 :: (a -> Print) -> NonEmpty a -> Print
csl1 :: forall a.
(a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a -> Reader PrintingOpts (Doc' ())
csl1 a -> Reader PrintingOpts (Doc' ())
f = (a -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> (a -> b -> b) -> NonEmpty a -> b
foldrMap1 a -> Reader PrintingOpts (Doc' ())
f ((a
  -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
 -> NonEmpty a -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (\Doc' ()
a Doc' ()
b -> Doc' ()
a Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
b) (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> a
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Reader PrintingOpts (Doc' ())
f

cslid1 :: PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 :: forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent a
f = PrettyIdent a
-> (a
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> NonEmpty a
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b. (a -> b) -> (a -> b -> b) -> NonEmpty a -> b
foldrMap1 PrettyIdent a
f ((a
  -> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
  -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
 -> NonEmpty a -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> (a
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> NonEmpty a
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b. (a -> b) -> a -> b
$ (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (\Doc' ()
x -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' ()
x Doc' () -> Doc' () -> Doc' ()
<.>)) (Reader PrintingOpts (Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> a
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent a
f

cslid :: Foldable f => Doc -> Doc -> PrettyIdent a -> f a -> Print
cslid :: forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
cslid Doc' ()
a Doc' ()
b PrettyIdent a
f = Reader PrintingOpts (Doc' ())
-> (NonEmpty a -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (NonEmpty a -> b) -> [a] -> b
nonEmpty (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Doc' ()
x -> Doc' ()
a Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
b) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent (NonEmpty a)
-> NonEmpty a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent a -> PrettyIdent (NonEmpty a)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent a
f)) ([a] -> Reader PrintingOpts (Doc' ()))
-> (f a -> [a]) -> f a -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> [a]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList

bcslid1 :: PrettyIdent a -> NonEmpty a -> Print
bcslid1 :: forall a.
PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
bcslid1 PrettyIdent a
f NonEmpty a
l = Doc' () -> Doc' ()
brc (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (NonEmpty a)
-> NonEmpty a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent a -> PrettyIdent (NonEmpty a)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent a -> PrettyIdent (NonEmpty a))
-> PrettyIdent a -> PrettyIdent (NonEmpty a)
forall a b. (a -> b) -> a -> b
$ PrettyIdent a -> PrettyIdent a
forall x. PrettyIdent x -> PrettyIdent x
mkg PrettyIdent a
f) NonEmpty a
l

pcslid :: Foldable f => PrettyIdent a -> f a -> Print
pcslid :: forall (f :: * -> *) a.
Foldable f =>
PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
pcslid PrettyIdent a
f = Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
cslid (Doc' ()
forall w. Doc' w
lparen Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
softspace) Doc' ()
forall w. Doc' w
rparen (PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ PrettyIdent a -> PrettyIdent a
forall x. PrettyIdent x -> PrettyIdent x
mkg PrettyIdent a
f

prettyBS :: PrettyIdent B.ByteString
prettyBS :: PrettyIdent ByteString
prettyBS ByteString
i = do
  Bool
bs <- (PrintingOpts -> Bool) -> ReaderT PrintingOpts Identity Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PrintingOpts -> Bool
_poEscapedSpace
  let si :: Bool
si = ByteString -> Bool
isIdentSimple ByteString
i
  (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return
    ( if Bool
si then ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i else Doc' ()
"\\" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> if Bool
bs then ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
space else ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i,
      if Bool
si Bool -> Bool -> Bool
|| Bool
bs then Doc' ()
forall w. Enum w => Doc' w
softline else Doc' ()
forall w. Enum w => Doc' w
newline
    )

prettyIdent :: PrettyIdent Identifier
prettyIdent :: PrettyIdent Identifier
prettyIdent (Identifier ByteString
i) = PrettyIdent ByteString
prettyBS ByteString
i

rawId :: Identifier -> Print
rawId :: Identifier -> Reader PrintingOpts (Doc' ())
rawId (Identifier ByteString
i) = do
  Bool
bs <- (PrintingOpts -> Bool) -> ReaderT PrintingOpts Identity Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PrintingOpts -> Bool
_poEscapedSpace
  let si :: Bool
si = ByteString -> Bool
isIdentSimple ByteString
i
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ if Bool
si then ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i else Doc' ()
"\\" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> if Bool
bs then ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
space else ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i

-- | Somehow the next eight function are very common patterns
pspWith :: PrettyIdent a -> Doc -> PrettyIdent a
pspWith :: forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
pspWith PrettyIdent a
f Doc' ()
d a
i = if Doc' () -> Bool
forall w. Doc' w -> Bool
nullDoc Doc' ()
d then PrettyIdent a
f a
i else (\(Doc' (), Doc' ())
x -> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
x Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
d) ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent a
f a
i Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid

padjWith :: PrettyIdent a -> Doc -> PrettyIdent a
padjWith :: forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent a
f Doc' ()
d a
i = if Doc' () -> Bool
forall w. Doc' w -> Bool
nullDoc Doc' ()
d then PrettyIdent a
f a
i else (Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
d) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent a
f a
i Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid

prettyEq :: Doc -> (Doc, Doc) -> (Doc, Doc)
prettyEq :: Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq Doc' ()
i = (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first ((Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b. (a -> b) -> a -> b
$ \Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
forall w. Doc' w
equals Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
x

prettyAttrng :: Attributes -> Doc -> Print
prettyAttrng :: Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a Doc' ()
x = (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
x) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Attributes
a

prettyItem :: Attributes -> Doc -> Print
prettyItem :: Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyItem Attributes
a Doc' ()
x = (Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a Doc' ()
x

prettyItems :: Doc -> (a -> Print) -> NonEmpty a -> Print
prettyItems :: forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems Doc' ()
h a -> Reader PrintingOpts (Doc' ())
f NonEmpty a
b = (\Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
h Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a -> Reader PrintingOpts (Doc' ())
forall a.
(a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a -> Reader PrintingOpts (Doc' ())
csl1 ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> a
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Reader PrintingOpts (Doc' ())
f) NonEmpty a
b

prettyItemsid :: Doc -> PrettyIdent a -> NonEmpty a -> Print
prettyItemsid :: forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
h PrettyIdent a
f NonEmpty a
b = (\Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
h Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (NonEmpty a)
-> NonEmpty a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj (PrettyIdent a -> PrettyIdent (NonEmpty a)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent a -> PrettyIdent (NonEmpty a))
-> PrettyIdent a -> PrettyIdent (NonEmpty a)
forall a b. (a -> b) -> a -> b
$ PrettyIdent a -> PrettyIdent a
forall x. PrettyIdent x -> PrettyIdent x
mkng PrettyIdent a
f) NonEmpty a
b

prettyAttrThen :: Attributes -> Print -> Print
prettyAttrThen :: Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen = (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<?=>) (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Attributes -> Reader PrintingOpts (Doc' ()))
-> Attributes
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr

prettyAttr :: Attributes -> Print
prettyAttr :: Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr = (Doc' () -> Doc' () -> Doc' ())
-> ([Attribute] -> Reader PrintingOpts (Doc' ()))
-> Attributes
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<=>) (([Attribute] -> Reader PrintingOpts (Doc' ()))
 -> Attributes -> Reader PrintingOpts (Doc' ()))
-> ([Attribute] -> Reader PrintingOpts (Doc' ()))
-> Attributes
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Reader PrintingOpts (Doc' ())
-> (NonEmpty Attribute -> Reader PrintingOpts (Doc' ()))
-> [Attribute]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (NonEmpty a -> b) -> [a] -> b
nonEmpty (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) ((NonEmpty Attribute -> Reader PrintingOpts (Doc' ()))
 -> [Attribute] -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty Attribute -> Reader PrintingOpts (Doc' ()))
-> [Attribute]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Doc' (), Doc' ())
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"(* " Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
x Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
"*)") (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty Attribute
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> NonEmpty Attribute
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Attribute
-> NonEmpty Attribute
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent Attribute
pa
  where
    pa :: PrettyIdent Attribute
pa (Attribute ByteString
i Maybe (GenExpr Identifier (Maybe CRangeExpr) ())
e) = ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> (GenExpr Identifier (Maybe CRangeExpr) ()
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> Maybe (GenExpr Identifier (Maybe CRangeExpr) ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (PrettyIdent ByteString
prettyBS ByteString
i) ((Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId (Identifier -> Reader PrintingOpts (Doc' ()))
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ByteString -> Identifier
Identifier ByteString
i) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> (GenExpr Identifier (Maybe CRangeExpr) ()
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> GenExpr Identifier (Maybe CRangeExpr) ()
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenExpr Identifier (Maybe CRangeExpr) ()
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall {a}. PrettyIdent (GenExpr Identifier (Maybe CRangeExpr) a)
pca) Maybe (GenExpr Identifier (Maybe CRangeExpr) ())
e
    pca :: PrettyIdent (GenExpr Identifier (Maybe CRangeExpr) a)
pca = PrettyIdent Identifier
-> (Maybe CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr Identifier (Maybe CRangeExpr) a)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent Identifier
prettyIdent ((CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CRangeExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm CRangeExpr -> Reader PrintingOpts (Doc' ())
prettyCRangeExpr) (Reader PrintingOpts (Doc' ()) -> a -> Reader PrintingOpts (Doc' ())
forall a b. a -> b -> a
const (Reader PrintingOpts (Doc' ())
 -> a -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> a
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) Int
12

prettyHierIdent :: PrettyIdent HierIdent
prettyHierIdent :: PrettyIdent HierIdent
prettyHierIdent (HierIdent [(Identifier, Maybe CExpr)]
p Identifier
i) = do
  (Doc' ()
ii, Doc' ()
s) <- PrettyIdent Identifier
prettyIdent Identifier
i
  Doc' ()
iii <- ((Identifier, Maybe CExpr)
 -> Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' ()
-> [(Identifier, Maybe CExpr)]
-> Reader PrintingOpts (Doc' ())
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> b -> m b) -> b -> t a -> m b
foldrM (\(Identifier, Maybe CExpr)
x Doc' ()
acc -> (\Doc' ()
d -> Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
dot Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
acc) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Identifier, Maybe CExpr) -> Reader PrintingOpts (Doc' ())
phId (Identifier, Maybe CExpr)
x) Doc' ()
ii [(Identifier, Maybe CExpr)]
p
  (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest Doc' ()
iii, Doc' ()
s)
  where
    phId :: (Identifier, Maybe CExpr) -> Reader PrintingOpts (Doc' ())
phId (Identifier
s, Maybe CExpr
r) =
      (CExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
brk) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (CExpr -> Reader PrintingOpts (Doc' ()))
-> CExpr
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent CExpr
prettyCExpr) Maybe CExpr
r Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
dr -> PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj (PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent Doc' ()
dr) Identifier
s

prettyDot1Ident :: PrettyIdent Dot1Ident
prettyDot1Ident :: PrettyIdent Dot1Ident
prettyDot1Ident (Dot1Ident Maybe ByteString
mh Identifier
t) = do
  (Doc' ()
i, Doc' ()
s) <- PrettyIdent Identifier
prettyIdent Identifier
t
  case Maybe ByteString
mh of Maybe ByteString
Nothing -> (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' ()
i, Doc' ()
s); Just ByteString
h -> (\Doc' ()
ft -> (Doc' ()
ft Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
dot Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
i, Doc' ()
s)) (Doc' () -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent ByteString
-> ByteString -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent ByteString
prettyBS ByteString
h

prettySpecTerm :: PrettyIdent SpecTerm
prettySpecTerm :: PrettyIdent SpecTerm
prettySpecTerm (SpecTerm Identifier
i Maybe CRangeExpr
r) = (CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CRangeExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm CRangeExpr -> Reader PrintingOpts (Doc' ())
prettyCRangeExpr Maybe CRangeExpr
r Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
d -> PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent Doc' ()
d Identifier
i

prettyNumber :: Number -> Doc
prettyNumber :: Number -> Doc' ()
prettyNumber Number
x = case Number
x of
  NBinary NonEmpty BXZ
l -> Doc' ()
"b" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> String -> Doc' ()
forall a. IsString a => String -> a
fromString ((BXZ -> String) -> NonEmpty BXZ -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap BXZ -> String
forall a. Show a => a -> String
show NonEmpty BXZ
l)
  NOctal NonEmpty OXZ
l -> Doc' ()
"o" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> String -> Doc' ()
forall a. IsString a => String -> a
fromString ((OXZ -> String) -> NonEmpty OXZ -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap OXZ -> String
forall a. Show a => a -> String
show NonEmpty OXZ
l)
  NDecimal Natural
i -> Doc' ()
"d" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Natural -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Natural
i
  NHex NonEmpty HXZ
l -> Doc' ()
"h" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> String -> Doc' ()
forall a. IsString a => String -> a
fromString ((HXZ -> String) -> NonEmpty HXZ -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap HXZ -> String
forall a. Show a => a -> String
show NonEmpty HXZ
l)
  NXZ Bool
b -> if Bool
b then Doc' ()
"dx" else Doc' ()
"dz"

prettyNumIdent :: PrettyIdent NumIdent
prettyNumIdent :: PrettyIdent NumIdent
prettyNumIdent NumIdent
x = case NumIdent
x of
  NIIdent Identifier
i -> PrettyIdent Identifier
prettyIdent Identifier
i
  NIReal ByteString
r -> PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
r
  NINumber Natural
n -> PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Natural -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Natural
n

prettyPrim :: PrettyIdent i -> (r -> Print) -> (a -> Print) -> PrettyIdent (GenPrim i r a)
prettyPrim :: forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (GenPrim i r a)
prettyPrim PrettyIdent i
ppid r -> Reader PrintingOpts (Doc' ())
ppr a -> Reader PrintingOpts (Doc' ())
ppa GenPrim i r a
x = case GenPrim i r a
x of
  PrimNumber Maybe Natural
Nothing Bool
True (NDecimal Natural
i) -> PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Natural -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Natural
i
  PrimNumber Maybe Natural
w Bool
b Number
n ->
    PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$
      Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$
        (case Maybe Natural
w of Maybe Natural
Nothing -> Doc' ()
forall a. Monoid a => a
mempty; Just Natural
ww -> Natural -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Natural
ww Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Enum w => Doc' w
softline)
          Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group ((if Bool
b then Doc' ()
"'s" else Doc' ()
forall w. Doc' w
squote) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Number -> Doc' ()
prettyNumber Number
n)
  PrimReal ByteString
r -> PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
r
  PrimIdent i
i r
r -> r -> Reader PrintingOpts (Doc' ())
ppr r
r Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
rng -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent i -> Doc' () -> PrettyIdent i
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent i
ppid (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
rng) i
i
  PrimConcat NonEmpty (GenExpr i r a)
l -> PrettyIdent (GenExpr i r a)
-> NonEmpty (GenExpr i r a) -> Reader PrintingOpts (Doc' ())
forall a.
PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
bcslid1 PrettyIdent (GenExpr i r a)
pexpr NonEmpty (GenExpr i r a)
l Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid
  PrimMultConcat GenExpr Identifier (Maybe CRangeExpr) a
e NonEmpty (GenExpr i r a)
l ->
    (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
(<>) (PrettyIdent (GenExpr Identifier (Maybe CRangeExpr) a)
-> GenExpr Identifier (Maybe CRangeExpr) a
-> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj (PrettyIdent Identifier
-> (Maybe CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr Identifier (Maybe CRangeExpr) a)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent Identifier
prettyIdent ((CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CRangeExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm CRangeExpr -> Reader PrintingOpts (Doc' ())
prettyCRangeExpr) a -> Reader PrintingOpts (Doc' ())
ppa Int
12) GenExpr Identifier (Maybe CRangeExpr) a
e) (PrettyIdent (GenExpr i r a)
-> NonEmpty (GenExpr i r a) -> Reader PrintingOpts (Doc' ())
forall a.
PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
bcslid1 PrettyIdent (GenExpr i r a)
pexpr NonEmpty (GenExpr i r a)
l)
      Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ())
-> (Doc' () -> Doc' ()) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
brc (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest
  PrimFun i
i a
a [GenExpr i r a]
l -> do
    Doc' ()
dat <- a -> Reader PrintingOpts (Doc' ())
ppa a
a
    Doc' ()
darg <- PrettyIdent (GenExpr i r a)
-> [GenExpr i r a] -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
pcslid PrettyIdent (GenExpr i r a)
pexpr [GenExpr i r a]
l
    (if Doc' () -> Bool
forall w. Doc' w -> Bool
nullDoc Doc' ()
dat then PrettyIdent i -> Doc' () -> PrettyIdent i
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith else PrettyIdent i -> Doc' () -> PrettyIdent i
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
pspWith) PrettyIdent i
ppid (Doc' ()
dat Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
darg) i
i
  PrimSysFun ByteString
i [GenExpr i r a]
l -> PrettyIdent (GenExpr i r a)
-> [GenExpr i r a] -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
pcslid PrettyIdent (GenExpr i r a)
pexpr [GenExpr i r a]
l Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ())
-> (Doc' () -> Doc' ()) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"$" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
x
  PrimMinTypMax GenMinTypMax (GenExpr i r a)
m -> PrettyIdent (GenMinTypMax (GenExpr i r a))
-> GenMinTypMax (GenExpr i r a) -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent (GenExpr i r a)
-> PrettyIdent (GenMinTypMax (GenExpr i r a))
forall et. PrettyIdent et -> PrettyIdent (GenMinTypMax et)
prettyGMTM PrettyIdent (GenExpr i r a)
pexpr) GenMinTypMax (GenExpr i r a)
m Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ())
-> (Doc' () -> Doc' ()) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par
  PrimString ByteString
x -> PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"\"" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"\""
  where pexpr :: PrettyIdent (GenExpr i r a)
pexpr = PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent i
ppid r -> Reader PrintingOpts (Doc' ())
ppr a -> Reader PrintingOpts (Doc' ())
ppa Int
12

preclevel :: BinaryOperator -> Int
preclevel :: BinaryOperator -> Int
preclevel BinaryOperator
b = case BinaryOperator
b of
  BinaryOperator
BinPower -> Int
1
  BinaryOperator
BinTimes -> Int
2
  BinaryOperator
BinDiv -> Int
2
  BinaryOperator
BinMod -> Int
2
  BinaryOperator
BinPlus -> Int
3
  BinaryOperator
BinMinus -> Int
3
  BinaryOperator
BinLSL -> Int
4
  BinaryOperator
BinLSR -> Int
4
  BinaryOperator
BinASL -> Int
4
  BinaryOperator
BinASR -> Int
4
  BinaryOperator
BinLT -> Int
5
  BinaryOperator
BinLEq -> Int
5
  BinaryOperator
BinGT -> Int
5
  BinaryOperator
BinGEq -> Int
5
  BinaryOperator
BinEq -> Int
6
  BinaryOperator
BinNEq -> Int
6
  BinaryOperator
BinCEq -> Int
6
  BinaryOperator
BinCNEq -> Int
6
  BinaryOperator
BinAnd -> Int
7
  BinaryOperator
BinXor -> Int
8
  BinaryOperator
BinXNor -> Int
8
  BinaryOperator
BinOr -> Int
9
  BinaryOperator
BinLAnd -> Int
10
  BinaryOperator
BinLOr -> Int
11

prettyGExpr :: PrettyIdent i -> (r -> Print) -> (a -> Print) -> Int -> PrettyIdent (GenExpr i r a)
prettyGExpr :: forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent i
ppid r -> Reader PrintingOpts (Doc' ())
ppr a -> Reader PrintingOpts (Doc' ())
ppa Int
l GenExpr i r a
e = case GenExpr i r a
e of
  ExprPrim GenPrim i r a
e -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (GenPrim i r a)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (GenPrim i r a)
prettyPrim PrettyIdent i
ppid r -> Reader PrintingOpts (Doc' ())
ppr a -> Reader PrintingOpts (Doc' ())
ppa GenPrim i r a
e
  ExprUnOp UnaryOperator
op a
a GenPrim i r a
e -> do
    Doc' ()
da <- a -> Reader PrintingOpts (Doc' ())
ppa a
a
    (Doc' ()
x, Doc' ()
s) <- PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (GenPrim i r a)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (GenPrim i r a)
prettyPrim PrettyIdent i
ppid r -> Reader PrintingOpts (Doc' ())
ppr a -> Reader PrintingOpts (Doc' ())
ppa GenPrim i r a
e
    (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ UnaryOperator -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow UnaryOperator
op Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Bool -> Doc' ()
piff (Doc' ()
forall w. Doc' w
space Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
da Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Enum w => Doc' w
newline) (Doc' () -> Bool
forall w. Doc' w -> Bool
nullDoc Doc' ()
da) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
x, Doc' ()
s)
  ExprBinOp GenExpr i r a
el BinaryOperator
op a
a GenExpr i r a
r -> do
    let
      p :: Int
p = BinaryOperator -> Int
preclevel BinaryOperator
op
      pp :: PrettyIdent (GenExpr i r a)
pp = Int -> PrettyIdent (GenExpr i r a)
pexpr (Int -> PrettyIdent (GenExpr i r a))
-> Int -> PrettyIdent (GenExpr i r a)
forall a b. (a -> b) -> a -> b
$ Int
p Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
    Doc' ()
ll <- (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> BinaryOperator -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow BinaryOperator
op) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> GenExpr i r a -> Reader PrintingOpts (Doc' ())
psexpr Int
p GenExpr i r a
el
    Doc' ()
da <- a -> Reader PrintingOpts (Doc' ())
ppa a
a
    case Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Int
l Int
p of
      Ordering
LT -> PrettyIdent (GenExpr i r a)
-> GenExpr i r a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent (GenExpr i r a)
pp GenExpr i r a
r Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
rr -> PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
ll Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> (Doc' ()
da Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
rr)
      Ordering
EQ -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (\Doc' ()
rr -> Doc' ()
ll Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> (Doc' ()
da Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
rr)) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (GenExpr i r a)
pp GenExpr i r a
r
      Ordering
GT -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (\Doc' ()
rr -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
ll Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> (Doc' ()
da Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
rr)) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (GenExpr i r a)
pp GenExpr i r a
r
  ExprCond GenExpr i r a
ec a
a GenExpr i r a
et GenExpr i r a
ef -> do
    Doc' ()
dc <- Int -> GenExpr i r a -> Reader PrintingOpts (Doc' ())
psexpr Int
11 GenExpr i r a
ec
    Doc' ()
dt <- Int -> GenExpr i r a -> Reader PrintingOpts (Doc' ())
psexpr Int
12 GenExpr i r a
et
    (Doc' (), Doc' ())
df <- Int -> PrettyIdent (GenExpr i r a)
pexpr Int
12 GenExpr i r a
ef
    Doc' ()
da <- a -> Reader PrintingOpts (Doc' ())
ppa a
a
    let
      pp :: (Doc' (), Doc' ())
pp = (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (\Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
dc Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' ()
"?" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?+> Doc' ()
da)) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
dt Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
x)) (Doc' (), Doc' ())
df
    if Int
l Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
12 then PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ (Doc' () -> Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> Doc' ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
(<>) (Doc' (), Doc' ())
pp else (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' (), Doc' ())
pp
  where
    pexpr :: Int -> PrettyIdent (GenExpr i r a)
pexpr = PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent i
ppid r -> Reader PrintingOpts (Doc' ())
ppr a -> Reader PrintingOpts (Doc' ())
ppa
    psexpr :: Int -> GenExpr i r a -> Reader PrintingOpts (Doc' ())
psexpr Int
n GenExpr i r a
e = (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> PrettyIdent (GenExpr i r a)
pexpr Int
n GenExpr i r a
e

prettyExpr :: PrettyIdent Expr
prettyExpr :: PrettyIdent Expr
prettyExpr (Expr GenExpr HierIdent (Maybe DimRange) Attributes
e) = PrettyIdent HierIdent
-> (Maybe DimRange -> Reader PrintingOpts (Doc' ()))
-> (Attributes -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr HierIdent (Maybe DimRange) Attributes)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent HierIdent
prettyHierIdent ((DimRange -> Reader PrintingOpts (Doc' ()))
-> Maybe DimRange -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm DimRange -> Reader PrintingOpts (Doc' ())
prettyDimRange) Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Int
12 GenExpr HierIdent (Maybe DimRange) Attributes
e

prettyCExpr :: PrettyIdent CExpr
prettyCExpr :: PrettyIdent CExpr
prettyCExpr (CExpr GenExpr Identifier (Maybe CRangeExpr) Attributes
e) = PrettyIdent Identifier
-> (Maybe CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> (Attributes -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr Identifier (Maybe CRangeExpr) Attributes)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent Identifier
prettyIdent ((CRangeExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CRangeExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm CRangeExpr -> Reader PrintingOpts (Doc' ())
prettyCRangeExpr) Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Int
12 GenExpr Identifier (Maybe CRangeExpr) Attributes
e

prettyGMTM :: PrettyIdent et -> PrettyIdent (GenMinTypMax et)
prettyGMTM :: forall et. PrettyIdent et -> PrettyIdent (GenMinTypMax et)
prettyGMTM PrettyIdent et
pp GenMinTypMax et
x = case GenMinTypMax et
x of
  MTMSingle et
e -> PrettyIdent et
pp et
e
  MTMFull et
l et
t et
h -> do
    Doc' ()
mn <- PrettyIdent et -> et -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent et
pp et
l
    Doc' ()
mt <- PrettyIdent et -> et -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent et
pp et
t
    (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (\Doc' ()
mx -> Doc' ()
mn Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<-> Doc' ()
mt Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<-> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
mx) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent et
pp et
h

prettyMTM :: PrettyIdent MinTypMax
prettyMTM :: PrettyIdent MinTypMax
prettyMTM = PrettyIdent Expr -> PrettyIdent MinTypMax
forall et. PrettyIdent et -> PrettyIdent (GenMinTypMax et)
prettyGMTM PrettyIdent Expr
prettyExpr

prettyCMTM :: PrettyIdent CMinTypMax
prettyCMTM :: PrettyIdent CMinTypMax
prettyCMTM = PrettyIdent CExpr -> PrettyIdent CMinTypMax
forall et. PrettyIdent et -> PrettyIdent (GenMinTypMax et)
prettyGMTM PrettyIdent CExpr
prettyCExpr

prettyRange2 :: Range2 -> Print
prettyRange2 :: Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2 (Range2 CExpr
m CExpr
l) = do
  Doc' ()
mx <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr CExpr
m
  Doc' ()
mn <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr CExpr
l
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
brk (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
mx Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<-> Doc' ()
mn

prettyR2s :: [Range2] -> Print
prettyR2s :: [Range2] -> Reader PrintingOpts (Doc' ())
prettyR2s = (Doc' () -> Doc' () -> Doc' ())
-> (Range2 -> Reader PrintingOpts (Doc' ()))
-> [Range2]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(</>) ((Range2 -> Reader PrintingOpts (Doc' ()))
 -> [Range2] -> Reader PrintingOpts (Doc' ()))
-> (Range2 -> Reader PrintingOpts (Doc' ()))
-> [Range2]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Range2 -> Reader PrintingOpts (Doc' ()))
-> Range2
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2

prettyRangeExpr :: PrettyIdent e -> GenRangeExpr e -> Print
prettyRangeExpr :: forall e.
PrettyIdent e -> GenRangeExpr e -> Reader PrintingOpts (Doc' ())
prettyRangeExpr PrettyIdent e
pp GenRangeExpr e
x = case GenRangeExpr e
x of
  GRESingle e
r -> Doc' () -> Doc' ()
brk (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent e -> e -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent e
pp e
r
  GREPair Range2
r2 -> Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2 Range2
r2
  GREBaseOff e
b Bool
mp CExpr
o -> do
    Doc' ()
base <- PrettyIdent e -> e -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent e
pp e
b
    Doc' ()
off <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr CExpr
o
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
brk (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
base Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (if Bool
mp then Doc' ()
"-" else Doc' ()
"+") Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<-> Doc' ()
off

prettyCRangeExpr :: CRangeExpr -> Print
prettyCRangeExpr :: CRangeExpr -> Reader PrintingOpts (Doc' ())
prettyCRangeExpr = PrettyIdent CExpr -> CRangeExpr -> Reader PrintingOpts (Doc' ())
forall e.
PrettyIdent e -> GenRangeExpr e -> Reader PrintingOpts (Doc' ())
prettyRangeExpr PrettyIdent CExpr
prettyCExpr

prettyGDR :: PrettyIdent e -> GenDimRange e -> Print
prettyGDR :: forall e.
PrettyIdent e -> GenDimRange e -> Reader PrintingOpts (Doc' ())
prettyGDR PrettyIdent e
pp (GenDimRange [e]
d GenRangeExpr e
r) =
  (e
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> [e]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(</>) (Doc' () -> Doc' () -> Doc' ())
-> (Doc' () -> Doc' ()) -> Doc' () -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
brk) (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (e -> Reader PrintingOpts (Doc' ()))
-> e
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent e -> e -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent e
pp) (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent e -> GenRangeExpr e -> Reader PrintingOpts (Doc' ())
forall e.
PrettyIdent e -> GenRangeExpr e -> Reader PrintingOpts (Doc' ())
prettyRangeExpr PrettyIdent e
pp GenRangeExpr e
r) [e]
d

prettyDimRange :: DimRange -> Print
prettyDimRange :: DimRange -> Reader PrintingOpts (Doc' ())
prettyDimRange = PrettyIdent Expr -> DimRange -> Reader PrintingOpts (Doc' ())
forall e.
PrettyIdent e -> GenDimRange e -> Reader PrintingOpts (Doc' ())
prettyGDR PrettyIdent Expr
prettyExpr

prettyCDimRange :: CDimRange -> Print
prettyCDimRange :: CDimRange -> Reader PrintingOpts (Doc' ())
prettyCDimRange = PrettyIdent CExpr -> CDimRange -> Reader PrintingOpts (Doc' ())
forall e.
PrettyIdent e -> GenDimRange e -> Reader PrintingOpts (Doc' ())
prettyGDR PrettyIdent CExpr
prettyCExpr

prettySignRange :: SignRange -> Print
prettySignRange :: SignRange -> Reader PrintingOpts (Doc' ())
prettySignRange (SignRange Bool
s Maybe Range2
r) = (Doc' () -> Bool -> Doc' ()
pift Doc' ()
"signed" Bool
s Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Range2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Range2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Range2 -> Reader PrintingOpts (Doc' ()))
-> Range2
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2) Maybe Range2
r

prettyComType :: (d -> Doc) -> ComType d -> Print
prettyComType :: forall d.
(d -> Doc' ()) -> ComType d -> Reader PrintingOpts (Doc' ())
prettyComType d -> Doc' ()
f ComType d
x = case ComType d
x of
  CTAbstract AbsType
t -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ AbsType -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow AbsType
t
  CTConcrete d
e SignRange
sr -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (d -> Doc' ()
f d
e Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SignRange -> Reader PrintingOpts (Doc' ())
prettySignRange SignRange
sr

prettyDriveStrength :: DriveStrength -> Doc
prettyDriveStrength :: DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
x = case DriveStrength
x of
  DSNormal Strength
StrStrong Strength
StrStrong -> Doc' ()
forall a. Monoid a => a
mempty
  DSNormal Strength
s0 Strength
s1 -> Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Strength -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Strength
s0 Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"0" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Strength -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Strength
s1 Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"1"
  DSHighZ Bool
False Strength
s -> Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"highz0" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Strength -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Strength
s Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"1"
  DSHighZ Bool
True Strength
s -> Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Strength -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Strength
s Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"0" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
"highz1"

prettyDelay3 :: PrettyIdent Delay3
prettyDelay3 :: PrettyIdent Delay3
prettyDelay3 Delay3
x =
  (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' ()
"#" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Delay3
x of
    D3Base NumIdent
ni -> PrettyIdent NumIdent
prettyNumIdent NumIdent
ni
    D31 MinTypMax
m -> PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent MinTypMax
prettyMTM MinTypMax
m Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ())
-> (Doc' () -> Doc' ()) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par
    D32 MinTypMax
m1 MinTypMax
m2 -> do
      Doc' ()
d1 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m1
      Doc' ()
d2 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m2
      PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
d1 Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
d2
    D33 MinTypMax
m1 MinTypMax
m2 MinTypMax
m3 -> do
      Doc' ()
d1 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m1
      Doc' ()
d2 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m2
      Doc' ()
d3 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m3
      PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
d1 Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
d2 Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
d3

prettyDelay2 :: PrettyIdent Delay2
prettyDelay2 :: PrettyIdent Delay2
prettyDelay2 Delay2
x =
  (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' ()
"#" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Delay2
x of
    D2Base NumIdent
ni -> PrettyIdent NumIdent
prettyNumIdent NumIdent
ni
    D21 MinTypMax
m -> PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent MinTypMax
prettyMTM MinTypMax
m Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ())
-> (Doc' () -> Doc' ()) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par
    D22 MinTypMax
m1 MinTypMax
m2 -> do
      Doc' ()
d1 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m1
      Doc' ()
d2 <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
m2
      PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
d1 Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
d2

prettyDelay1 :: PrettyIdent Delay1
prettyDelay1 :: PrettyIdent Delay1
prettyDelay1 Delay1
x =
  (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' ()
"#" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Delay1
x of
    D1Base NumIdent
ni -> PrettyIdent NumIdent
prettyNumIdent NumIdent
ni
    D11 MinTypMax
m -> PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent MinTypMax
prettyMTM MinTypMax
m Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ())
-> (Doc' () -> Doc' ()) -> PrettyIdent (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par

prettyLValue :: (dr -> Print) -> PrettyIdent (LValue dr)
prettyLValue :: forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
prettyLValue dr -> Reader PrintingOpts (Doc' ())
f LValue dr
x = case LValue dr
x of
  LVSingle HierIdent
hi Maybe dr
r -> (dr -> Reader PrintingOpts (Doc' ()))
-> Maybe dr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (dr -> Reader PrintingOpts (Doc' ()))
-> dr
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. dr -> Reader PrintingOpts (Doc' ())
f) Maybe dr
r Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
rng -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent HierIdent -> Doc' () -> PrettyIdent HierIdent
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent HierIdent
prettyHierIdent Doc' ()
rng HierIdent
hi
  LVConcat NonEmpty (LValue dr)
l -> PrettyIdent (LValue dr)
-> NonEmpty (LValue dr) -> Reader PrintingOpts (Doc' ())
forall a.
PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
bcslid1 ((dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
prettyLValue dr -> Reader PrintingOpts (Doc' ())
f) NonEmpty (LValue dr)
l Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid 

prettyNetLV :: PrettyIdent NetLValue
prettyNetLV :: PrettyIdent NetLValue
prettyNetLV = (CDimRange -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent NetLValue
forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
prettyLValue CDimRange -> Reader PrintingOpts (Doc' ())
prettyCDimRange

prettyVarLV :: PrettyIdent VarLValue
prettyVarLV :: PrettyIdent VarLValue
prettyVarLV = (DimRange -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent VarLValue
forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
prettyLValue DimRange -> Reader PrintingOpts (Doc' ())
prettyDimRange

prettyAssign :: (dr -> Print) -> PrettyIdent (Assign dr)
prettyAssign :: forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (Assign dr)
prettyAssign dr -> Reader PrintingOpts (Doc' ())
f (Assign LValue dr
l Expr
e) = ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ((Doc' (), Doc' ()) -> Doc' ())
-> (Doc' (), Doc' ())
-> (Doc' (), Doc' ())
-> (Doc' (), Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst) ((dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (LValue dr)
prettyLValue dr -> Reader PrintingOpts (Doc' ())
f LValue dr
l) (PrettyIdent Expr
prettyExpr Expr
e)

prettyNetAssign :: PrettyIdent NetAssign
prettyNetAssign :: PrettyIdent NetAssign
prettyNetAssign = (CDimRange -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent NetAssign
forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (Assign dr)
prettyAssign CDimRange -> Reader PrintingOpts (Doc' ())
prettyCDimRange

prettyVarAssign :: PrettyIdent VarAssign
prettyVarAssign :: PrettyIdent VarAssign
prettyVarAssign = (DimRange -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent VarAssign
forall dr.
(dr -> Reader PrintingOpts (Doc' ())) -> PrettyIdent (Assign dr)
prettyAssign DimRange -> Reader PrintingOpts (Doc' ())
prettyDimRange

prettyEventControl :: PrettyIdent EventControl
prettyEventControl :: PrettyIdent EventControl
prettyEventControl EventControl
x =
  (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' ()
"@" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case EventControl
x of
    EventControl
ECDeps -> (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' ()
"*", Doc' ()
forall w. Enum w => Doc' w
newline)
    ECIdent HierIdent
hi -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent HierIdent
prettyHierIdent HierIdent
hi
    ECExpr NonEmpty EventPrim
l -> (\Doc' ()
e -> (Doc' () -> Doc' ()
gpar Doc' ()
e, Doc' ()
forall w. Enum w => Doc' w
newline)) (Doc' () -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (NonEmpty EventPrim)
-> NonEmpty EventPrim -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent EventPrim -> PrettyIdent (NonEmpty EventPrim)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent EventPrim
pEP) NonEmpty EventPrim
l
  where
    pEP :: PrettyIdent EventPrim
pEP (EventPrim EventPrefix
p Expr
e) =
      (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((case EventPrefix
p of EventPrefix
EPAny -> Doc' ()
forall a. Monoid a => a
mempty; EventPrefix
EPPos -> Doc' ()
"posedge"; EventPrefix
EPNeg -> Doc' ()
"negedge") Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=>))
        ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Expr
prettyExpr Expr
e

prettyEdgeDesc :: EdgeDesc -> Print
prettyEdgeDesc :: EdgeDesc -> Reader PrintingOpts (Doc' ())
prettyEdgeDesc EdgeDesc
x = do
  Bool
zx <- (PrintingOpts -> Bool) -> ReaderT PrintingOpts Identity Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PrintingOpts -> Bool
_poEdgeControlZ_X
  if EdgeDesc
x EdgeDesc -> EdgeDesc -> Bool
forall a. Eq a => a -> a -> Bool
== [Bool] -> EdgeDesc
forall a. Unbox a => [a] -> Vector a
V.fromList [Bool
Item [Bool]
True, Bool
Item [Bool]
True, Bool
Item [Bool]
False, Bool
Item [Bool]
False, Bool
Item [Bool]
False, Bool
Item [Bool]
True]
    then Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
"posedge"
    else
      if EdgeDesc
x EdgeDesc -> EdgeDesc -> Bool
forall a. Eq a => a -> a -> Bool
== [Bool] -> EdgeDesc
forall a. Unbox a => [a] -> Vector a
V.fromList [Bool
Item [Bool]
False, Bool
Item [Bool]
False, Bool
Item [Bool]
True, Bool
Item [Bool]
True, Bool
Item [Bool]
True, Bool
Item [Bool]
False]
        then Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
"negedge"
        else
          (\Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"edge" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
brk Doc' ()
x)
            (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Doc' ()
-> Doc' ()
-> (ByteString -> Reader PrintingOpts (Doc' ()))
-> [ByteString]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
csl Doc' ()
forall a. Monoid a => a
mempty Doc' ()
forall a. Monoid a => a
mempty (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' () -> Reader PrintingOpts (Doc' ()))
-> (ByteString -> Doc' ())
-> ByteString
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw) ((Int -> Bool -> [ByteString] -> [ByteString])
-> [ByteString] -> EdgeDesc -> [ByteString]
forall a b. Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b
V.ifoldr (Bool -> Int -> Bool -> [ByteString] -> [ByteString]
forall {a} {a}.
(Eq a, Num a, IsString a) =>
Bool -> a -> Bool -> [a] -> [a]
pED Bool
zx) [] EdgeDesc
x)
  where
    pED :: Bool -> a -> Bool -> [a] -> [a]
pED Bool
zx a
i Bool
b =
      if Bool
b
        then (:) (a -> [a] -> [a]) -> a -> [a] -> [a]
forall a b. (a -> b) -> a -> b
$ case a
i of
          a
0 -> a
"01"
          a
1 -> if Bool
zx then a
"0z" else a
"0x"
          a
2 -> a
"10"
          a
3 -> if Bool
zx then a
"1z" else a
"1x"
          a
4 -> if Bool
zx then a
"z0" else a
"x0"
          a
5 -> if Bool
zx then a
"z1" else a
"x1"
        else [a] -> [a]
forall a. a -> a
id

prettyXparam :: B.ByteString -> ComType () -> NonEmpty (Identified CMinTypMax) -> Print
prettyXparam :: ByteString
-> ComType ()
-> NonEmpty (Identified CMinTypMax)
-> Reader PrintingOpts (Doc' ())
prettyXparam ByteString
pre ComType ()
t NonEmpty (Identified CMinTypMax)
l = do
  Doc' ()
dt <- (() -> Doc' ()) -> ComType () -> Reader PrintingOpts (Doc' ())
forall d.
(d -> Doc' ()) -> ComType d -> Reader PrintingOpts (Doc' ())
prettyComType (Doc' () -> () -> Doc' ()
forall a b. a -> b -> a
const Doc' ()
forall a. Monoid a => a
mempty) ComType ()
t
  Doc' ()
-> PrettyIdent (Identified CMinTypMax)
-> NonEmpty (Identified CMinTypMax)
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid
    (ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
pre Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dt)
    (\(Identified Identifier
i CMinTypMax
v) -> (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
i) (PrettyIdent CMinTypMax
prettyCMTM CMinTypMax
v))
    NonEmpty (Identified CMinTypMax)
l

type EDI = Either [Range2] CExpr

data AllBlockDecl
  = ABDReg SignRange (NonEmpty (Identified EDI))
  | ABDInt (NonEmpty (Identified EDI))
  | ABDReal (NonEmpty (Identified EDI))
  | ABDTime (NonEmpty (Identified EDI))
  | ABDRealTime (NonEmpty (Identified EDI))
  | ABDEvent (NonEmpty (Identified [Range2]))
  | ABDLocalParam (ComType ()) (NonEmpty (Identified CMinTypMax))
  | ABDParameter (ComType ()) (NonEmpty (Identified CMinTypMax))
  | ABDPort Dir (ComType Bool) (NonEmpty Identifier)

fromBlockDecl ::
  (forall x. f x -> NonEmpty (Identified x)) -> (t -> EDI) -> BlockDecl f t -> AllBlockDecl
fromBlockDecl :: forall (f :: * -> *) t.
(forall x. f x -> NonEmpty (Identified x))
-> (t -> EDI) -> BlockDecl f t -> AllBlockDecl
fromBlockDecl forall x. f x -> NonEmpty (Identified x)
ff t -> EDI
ft BlockDecl f t
bd = case BlockDecl f t
bd of
  BDReg SignRange
sr f t
x -> (NonEmpty (Identified EDI) -> AllBlockDecl) -> f t -> AllBlockDecl
forall {c}. (NonEmpty (Identified EDI) -> c) -> f t -> c
convt (SignRange -> NonEmpty (Identified EDI) -> AllBlockDecl
ABDReg SignRange
sr) f t
x
  BDInt f t
x -> (NonEmpty (Identified EDI) -> AllBlockDecl) -> f t -> AllBlockDecl
forall {c}. (NonEmpty (Identified EDI) -> c) -> f t -> c
convt NonEmpty (Identified EDI) -> AllBlockDecl
ABDInt f t
x
  BDReal f t
x -> (NonEmpty (Identified EDI) -> AllBlockDecl) -> f t -> AllBlockDecl
forall {c}. (NonEmpty (Identified EDI) -> c) -> f t -> c
convt NonEmpty (Identified EDI) -> AllBlockDecl
ABDReal f t
x
  BDTime f t
x -> (NonEmpty (Identified EDI) -> AllBlockDecl) -> f t -> AllBlockDecl
forall {c}. (NonEmpty (Identified EDI) -> c) -> f t -> c
convt NonEmpty (Identified EDI) -> AllBlockDecl
ABDTime f t
x
  BDRealTime f t
x -> (NonEmpty (Identified EDI) -> AllBlockDecl) -> f t -> AllBlockDecl
forall {c}. (NonEmpty (Identified EDI) -> c) -> f t -> c
convt NonEmpty (Identified EDI) -> AllBlockDecl
ABDRealTime f t
x
  BDEvent f [Range2]
r2 -> (NonEmpty (Identified [Range2]) -> AllBlockDecl)
-> f [Range2] -> AllBlockDecl
forall {x} {c}. (NonEmpty (Identified x) -> c) -> f x -> c
conv NonEmpty (Identified [Range2]) -> AllBlockDecl
ABDEvent f [Range2]
r2
  BDLocalParam ComType ()
t f CMinTypMax
v -> (NonEmpty (Identified CMinTypMax) -> AllBlockDecl)
-> f CMinTypMax -> AllBlockDecl
forall {x} {c}. (NonEmpty (Identified x) -> c) -> f x -> c
conv (ComType () -> NonEmpty (Identified CMinTypMax) -> AllBlockDecl
ABDLocalParam ComType ()
t) f CMinTypMax
v
  where
    conv :: (NonEmpty (Identified x) -> c) -> f x -> c
conv NonEmpty (Identified x) -> c
c = NonEmpty (Identified x) -> c
c (NonEmpty (Identified x) -> c)
-> (f x -> NonEmpty (Identified x)) -> f x -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f x -> NonEmpty (Identified x)
forall x. f x -> NonEmpty (Identified x)
ff
    convt :: (NonEmpty (Identified EDI) -> c) -> f t -> c
convt NonEmpty (Identified EDI) -> c
c = NonEmpty (Identified EDI) -> c
c (NonEmpty (Identified EDI) -> c)
-> (f t -> NonEmpty (Identified EDI)) -> f t -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Identified t -> Identified EDI)
-> NonEmpty (Identified t) -> NonEmpty (Identified EDI)
forall a b. (a -> b) -> NonEmpty a -> NonEmpty b
NE.map (\(Identified Identifier
i t
x) -> Identifier -> EDI -> Identified EDI
forall t. Identifier -> t -> Identified t
Identified Identifier
i (EDI -> Identified EDI) -> EDI -> Identified EDI
forall a b. (a -> b) -> a -> b
$ t -> EDI
ft t
x) (NonEmpty (Identified t) -> NonEmpty (Identified EDI))
-> (f t -> NonEmpty (Identified t))
-> f t
-> NonEmpty (Identified EDI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f t -> NonEmpty (Identified t)
forall x. f x -> NonEmpty (Identified x)
ff

fromStdBlockDecl :: AttrIded StdBlockDecl -> Attributed AllBlockDecl
fromStdBlockDecl :: AttrIded StdBlockDecl -> Attributed AllBlockDecl
fromStdBlockDecl (AttrIded Attributes
a Identifier
i StdBlockDecl
sbd) =
  Attributes -> AllBlockDecl -> Attributed AllBlockDecl
forall t. Attributes -> t -> Attributed t
Attributed Attributes
a (AllBlockDecl -> Attributed AllBlockDecl)
-> AllBlockDecl -> Attributed AllBlockDecl
forall a b. (a -> b) -> a -> b
$ case StdBlockDecl
sbd of
    SBDParameter (Parameter ComType ()
t CMinTypMax
v) -> ComType () -> NonEmpty (Identified CMinTypMax) -> AllBlockDecl
ABDParameter ComType ()
t [Identifier -> CMinTypMax -> Identified CMinTypMax
forall t. Identifier -> t -> Identified t
Identified Identifier
i CMinTypMax
v]
    SBDBlockDecl BlockDecl Identity [Range2]
bd -> (forall x. Identity x -> NonEmpty (Identified x))
-> ([Range2] -> EDI) -> BlockDecl Identity [Range2] -> AllBlockDecl
forall (f :: * -> *) t.
(forall x. f x -> NonEmpty (Identified x))
-> (t -> EDI) -> BlockDecl f t -> AllBlockDecl
fromBlockDecl ((Identified x -> [Identified x] -> NonEmpty (Identified x)
forall a. a -> [a] -> NonEmpty a
:|[]) (Identified x -> NonEmpty (Identified x))
-> (Identity x -> Identified x)
-> Identity x
-> NonEmpty (Identified x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identifier -> x -> Identified x
forall t. Identifier -> t -> Identified t
Identified Identifier
i (x -> Identified x)
-> (Identity x -> x) -> Identity x -> Identified x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity x -> x
forall a. Identity a -> a
runIdentity) [Range2] -> EDI
forall a b. a -> Either a b
Left BlockDecl Identity [Range2]
bd
    
prettyAllBlockDecl :: AllBlockDecl -> Print
prettyAllBlockDecl :: AllBlockDecl -> Reader PrintingOpts (Doc' ())
prettyAllBlockDecl AllBlockDecl
x = case AllBlockDecl
x of
  ABDReg SignRange
sr NonEmpty (Identified EDI)
l -> SignRange -> Reader PrintingOpts (Doc' ())
prettySignRange SignRange
sr Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
dsr -> Doc' ()
-> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ())
mkedi (Doc' ()
"reg" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dsr) NonEmpty (Identified EDI)
l
  ABDInt NonEmpty (Identified EDI)
l -> Doc' ()
-> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ())
mkedi Doc' ()
"integer" NonEmpty (Identified EDI)
l
  ABDReal NonEmpty (Identified EDI)
l -> Doc' ()
-> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ())
mkedi Doc' ()
"real" NonEmpty (Identified EDI)
l
  ABDTime NonEmpty (Identified EDI)
l -> Doc' ()
-> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ())
mkedi Doc' ()
"time" NonEmpty (Identified EDI)
l
  ABDRealTime NonEmpty (Identified EDI)
l -> Doc' ()
-> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ())
mkedi Doc' ()
"realtime" NonEmpty (Identified EDI)
l
  ABDEvent NonEmpty (Identified [Range2])
l ->
    Doc' ()
-> PrettyIdent (Identified [Range2])
-> NonEmpty (Identified [Range2])
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
"event" (\(Identified Identifier
i [Range2]
r) -> [Range2] -> Reader PrintingOpts (Doc' ())
prettyR2s [Range2]
r Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
dr -> PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent Doc' ()
dr Identifier
i) NonEmpty (Identified [Range2])
l
  ABDLocalParam ComType ()
t NonEmpty (Identified CMinTypMax)
l -> ByteString
-> ComType ()
-> NonEmpty (Identified CMinTypMax)
-> Reader PrintingOpts (Doc' ())
prettyXparam ByteString
"localparam" ComType ()
t NonEmpty (Identified CMinTypMax)
l
  ABDParameter ComType ()
t NonEmpty (Identified CMinTypMax)
l -> ByteString
-> ComType ()
-> NonEmpty (Identified CMinTypMax)
-> Reader PrintingOpts (Doc' ())
prettyXparam ByteString
"parameter" ComType ()
t NonEmpty (Identified CMinTypMax)
l
  ABDPort Dir
d ComType Bool
t NonEmpty Identifier
l ->
    (Bool -> Doc' ()) -> ComType Bool -> Reader PrintingOpts (Doc' ())
forall d.
(d -> Doc' ()) -> ComType d -> Reader PrintingOpts (Doc' ())
prettyComType (Doc' () -> Bool -> Doc' ()
pift Doc' ()
"reg") ComType Bool
t Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
dt -> Doc' ()
-> PrettyIdent Identifier
-> NonEmpty Identifier
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (Dir -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Dir
d Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dt) PrettyIdent Identifier
prettyIdent NonEmpty Identifier
l
  where
    mkedi :: Doc' ()
-> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ())
mkedi Doc' ()
h =
      Doc' ()
-> PrettyIdent (Identified EDI)
-> NonEmpty (Identified EDI)
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
h (PrettyIdent (Identified EDI)
 -> NonEmpty (Identified EDI) -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (Identified EDI)
-> NonEmpty (Identified EDI)
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
        \(Identified Identifier
i EDI
edi) -> case EDI
edi of
          Left [Range2]
r2 -> [Range2] -> Reader PrintingOpts (Doc' ())
prettyR2s [Range2]
r2 Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
dim -> PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
dim) Identifier
i
          Right CExpr
ce -> (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
i) (PrettyIdent CExpr
prettyCExpr CExpr
ce)

prettyAllBlockDecls :: [Attributed AllBlockDecl] -> Print
prettyAllBlockDecls :: [Attributed AllBlockDecl] -> Reader PrintingOpts (Doc' ())
prettyAllBlockDecls =
  Reader PrintingOpts (Doc' ())
-> (NonEmpty (Attributed AllBlockDecl)
    -> Reader PrintingOpts (Doc' ()))
-> [Attributed AllBlockDecl]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (NonEmpty a -> b) -> [a] -> b
nonEmpty (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) ((NonEmpty (Attributed AllBlockDecl)
  -> Reader PrintingOpts (Doc' ()))
 -> [Attributed AllBlockDecl] -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty (Attributed AllBlockDecl)
    -> Reader PrintingOpts (Doc' ()))
-> [Attributed AllBlockDecl]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
    (Doc' () -> Doc' () -> Doc' ())
-> (Attributed AllBlockDecl -> Reader PrintingOpts (Doc' ()))
-> (Attributed AllBlockDecl -> Attributed AllBlockDecl)
-> (Attributed AllBlockDecl
    -> Attributed AllBlockDecl -> Maybe (Attributed AllBlockDecl))
-> NonEmpty (Attributed AllBlockDecl)
-> Reader PrintingOpts (Doc' ())
forall y x.
(Doc' () -> Doc' () -> Doc' ())
-> (y -> Reader PrintingOpts (Doc' ()))
-> (x -> y)
-> (x -> y -> Maybe y)
-> NonEmpty x
-> Reader PrintingOpts (Doc' ())
prettyregroup
      Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>)
      (\(Attributed Attributes
a AllBlockDecl
abd) -> AllBlockDecl -> Reader PrintingOpts (Doc' ())
prettyAllBlockDecl AllBlockDecl
abd Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a)
      Attributed AllBlockDecl -> Attributed AllBlockDecl
forall a. a -> a
id
      ((AllBlockDecl -> AllBlockDecl -> Maybe AllBlockDecl)
-> Attributed AllBlockDecl
-> Attributed AllBlockDecl
-> Maybe (Attributed AllBlockDecl)
forall x y.
(x -> y -> Maybe y)
-> Attributed x -> Attributed y -> Maybe (Attributed y)
addAttributed ((AllBlockDecl -> AllBlockDecl -> Maybe AllBlockDecl)
 -> Attributed AllBlockDecl
 -> Attributed AllBlockDecl
 -> Maybe (Attributed AllBlockDecl))
-> (AllBlockDecl -> AllBlockDecl -> Maybe AllBlockDecl)
-> Attributed AllBlockDecl
-> Attributed AllBlockDecl
-> Maybe (Attributed AllBlockDecl)
forall a b. (a -> b) -> a -> b
$ \AllBlockDecl
x AllBlockDecl
y -> case (AllBlockDecl
x, AllBlockDecl
y) of
        (ABDReg SignRange
nsr NonEmpty (Identified EDI)
nl, ABDReg SignRange
sr NonEmpty (Identified EDI)
l) | SignRange
nsr SignRange -> SignRange -> Bool
forall a. Eq a => a -> a -> Bool
== SignRange
sr -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ SignRange -> NonEmpty (Identified EDI) -> AllBlockDecl
ABDReg SignRange
sr (NonEmpty (Identified EDI) -> AllBlockDecl)
-> NonEmpty (Identified EDI) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI)
nl NonEmpty (Identified EDI)
-> NonEmpty (Identified EDI) -> NonEmpty (Identified EDI)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified EDI)
l
        (ABDInt NonEmpty (Identified EDI)
nl, ABDInt NonEmpty (Identified EDI)
l) -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI) -> AllBlockDecl
ABDInt (NonEmpty (Identified EDI) -> AllBlockDecl)
-> NonEmpty (Identified EDI) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI)
nl NonEmpty (Identified EDI)
-> NonEmpty (Identified EDI) -> NonEmpty (Identified EDI)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified EDI)
l
        (ABDReal NonEmpty (Identified EDI)
nl, ABDReal NonEmpty (Identified EDI)
l) -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI) -> AllBlockDecl
ABDReal (NonEmpty (Identified EDI) -> AllBlockDecl)
-> NonEmpty (Identified EDI) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI)
nl NonEmpty (Identified EDI)
-> NonEmpty (Identified EDI) -> NonEmpty (Identified EDI)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified EDI)
l
        (ABDTime NonEmpty (Identified EDI)
nl, ABDTime NonEmpty (Identified EDI)
l) -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI) -> AllBlockDecl
ABDTime (NonEmpty (Identified EDI) -> AllBlockDecl)
-> NonEmpty (Identified EDI) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI)
nl NonEmpty (Identified EDI)
-> NonEmpty (Identified EDI) -> NonEmpty (Identified EDI)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified EDI)
l
        (ABDRealTime NonEmpty (Identified EDI)
nl, ABDRealTime NonEmpty (Identified EDI)
l) -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI) -> AllBlockDecl
ABDRealTime (NonEmpty (Identified EDI) -> AllBlockDecl)
-> NonEmpty (Identified EDI) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified EDI)
nl NonEmpty (Identified EDI)
-> NonEmpty (Identified EDI) -> NonEmpty (Identified EDI)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified EDI)
l
        (ABDEvent NonEmpty (Identified [Range2])
nl, ABDEvent NonEmpty (Identified [Range2])
l) -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified [Range2]) -> AllBlockDecl
ABDEvent (NonEmpty (Identified [Range2]) -> AllBlockDecl)
-> NonEmpty (Identified [Range2]) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified [Range2])
nl NonEmpty (Identified [Range2])
-> NonEmpty (Identified [Range2]) -> NonEmpty (Identified [Range2])
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified [Range2])
l
        (ABDLocalParam ComType ()
nt NonEmpty (Identified CMinTypMax)
nl, ABDLocalParam ComType ()
t NonEmpty (Identified CMinTypMax)
l) | ComType ()
nt ComType () -> ComType () -> Bool
forall a. Eq a => a -> a -> Bool
== ComType ()
t -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ ComType () -> NonEmpty (Identified CMinTypMax) -> AllBlockDecl
ABDLocalParam ComType ()
t (NonEmpty (Identified CMinTypMax) -> AllBlockDecl)
-> NonEmpty (Identified CMinTypMax) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified CMinTypMax)
nl NonEmpty (Identified CMinTypMax)
-> NonEmpty (Identified CMinTypMax)
-> NonEmpty (Identified CMinTypMax)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified CMinTypMax)
l
        (ABDParameter ComType ()
nt NonEmpty (Identified CMinTypMax)
nl, ABDParameter ComType ()
t NonEmpty (Identified CMinTypMax)
l) | ComType ()
nt ComType () -> ComType () -> Bool
forall a. Eq a => a -> a -> Bool
== ComType ()
t -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ ComType () -> NonEmpty (Identified CMinTypMax) -> AllBlockDecl
ABDParameter ComType ()
t (NonEmpty (Identified CMinTypMax) -> AllBlockDecl)
-> NonEmpty (Identified CMinTypMax) -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty (Identified CMinTypMax)
nl NonEmpty (Identified CMinTypMax)
-> NonEmpty (Identified CMinTypMax)
-> NonEmpty (Identified CMinTypMax)
forall a. Semigroup a => a -> a -> a
<> NonEmpty (Identified CMinTypMax)
l
        (ABDPort Dir
nd ComType Bool
nt NonEmpty Identifier
nl, ABDPort Dir
d ComType Bool
t NonEmpty Identifier
l) | Dir
nd Dir -> Dir -> Bool
forall a. Eq a => a -> a -> Bool
== Dir
d Bool -> Bool -> Bool
&& ComType Bool
nt ComType Bool -> ComType Bool -> Bool
forall a. Eq a => a -> a -> Bool
== ComType Bool
t -> AllBlockDecl -> Maybe AllBlockDecl
forall a. a -> Maybe a
Just (AllBlockDecl -> Maybe AllBlockDecl)
-> AllBlockDecl -> Maybe AllBlockDecl
forall a b. (a -> b) -> a -> b
$ Dir -> ComType Bool -> NonEmpty Identifier -> AllBlockDecl
ABDPort Dir
d ComType Bool
t (NonEmpty Identifier -> AllBlockDecl)
-> NonEmpty Identifier -> AllBlockDecl
forall a b. (a -> b) -> a -> b
$ NonEmpty Identifier
nl NonEmpty Identifier -> NonEmpty Identifier -> NonEmpty Identifier
forall a. Semigroup a => a -> a -> a
<> NonEmpty Identifier
l
        (AllBlockDecl, AllBlockDecl)
_ -> Maybe AllBlockDecl
forall a. Maybe a
Nothing
      )

prettyStdBlockDecls :: [AttrIded StdBlockDecl] -> Print
prettyStdBlockDecls :: [AttrIded StdBlockDecl] -> Reader PrintingOpts (Doc' ())
prettyStdBlockDecls = [Attributed AllBlockDecl] -> Reader PrintingOpts (Doc' ())
prettyAllBlockDecls ([Attributed AllBlockDecl] -> Reader PrintingOpts (Doc' ()))
-> ([AttrIded StdBlockDecl] -> [Attributed AllBlockDecl])
-> [AttrIded StdBlockDecl]
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AttrIded StdBlockDecl -> Attributed AllBlockDecl)
-> [AttrIded StdBlockDecl] -> [Attributed AllBlockDecl]
forall a b. (a -> b) -> [a] -> [b]
map AttrIded StdBlockDecl -> Attributed AllBlockDecl
fromStdBlockDecl

prettyTFBlockDecls :: (d -> Dir) -> [AttrIded (TFBlockDecl d)] -> Print
prettyTFBlockDecls :: forall d.
(d -> Dir)
-> [AttrIded (TFBlockDecl d)] -> Reader PrintingOpts (Doc' ())
prettyTFBlockDecls d -> Dir
f =
  [Attributed AllBlockDecl] -> Reader PrintingOpts (Doc' ())
prettyAllBlockDecls
    ([Attributed AllBlockDecl] -> Reader PrintingOpts (Doc' ()))
-> ([AttrIded (TFBlockDecl d)] -> [Attributed AllBlockDecl])
-> [AttrIded (TFBlockDecl d)]
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AttrIded (TFBlockDecl d) -> Attributed AllBlockDecl)
-> [AttrIded (TFBlockDecl d)] -> [Attributed AllBlockDecl]
forall a b. (a -> b) -> [a] -> [b]
map
      ( \(AttrIded Attributes
a Identifier
i TFBlockDecl d
x) -> case TFBlockDecl d
x of
          TFBDPort d
d ComType Bool
t -> Attributes -> AllBlockDecl -> Attributed AllBlockDecl
forall t. Attributes -> t -> Attributed t
Attributed Attributes
a (AllBlockDecl -> Attributed AllBlockDecl)
-> AllBlockDecl -> Attributed AllBlockDecl
forall a b. (a -> b) -> a -> b
$ Dir -> ComType Bool -> NonEmpty Identifier -> AllBlockDecl
ABDPort (d -> Dir
f d
d) ComType Bool
t [Item (NonEmpty Identifier)
Identifier
i]
          TFBDStd StdBlockDecl
sbd -> AttrIded StdBlockDecl -> Attributed AllBlockDecl
fromStdBlockDecl (Attributes -> Identifier -> StdBlockDecl -> AttrIded StdBlockDecl
forall t. Attributes -> Identifier -> t -> AttrIded t
AttrIded Attributes
a Identifier
i StdBlockDecl
sbd)
      )

prettyStatement :: Bool -> Statement -> Print
prettyStatement :: Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
protect Statement
x = case Statement
x of
  SBlockAssign Bool
b (Assign VarLValue
lv Expr
v) Maybe DelayEventControl
dec -> do
    Doc' ()
delev <- case Maybe DelayEventControl
dec of
      Maybe DelayEventControl
Nothing -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty
      Just (DECRepeat Expr
e EventControl
ev) -> do
        Doc' ()
ex <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
e
        (Doc' (), Doc' ())
evc <- PrettyIdent EventControl
prettyEventControl EventControl
ev
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
"repeat" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
gpar Doc' ()
ex) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
evc
      Just (DECDelay Delay1
d) -> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Delay1
prettyDelay1 Delay1
d
      Just (DECEvent EventControl
e) -> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent EventControl
prettyEventControl EventControl
e
    (Doc' (), Doc' ())
ll <- PrettyIdent VarLValue
prettyVarLV VarLValue
lv
    Doc' ()
rr <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent Expr
prettyExpr Expr
v
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group ((Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
ll) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Bool -> Doc' ()
piff Doc' ()
forall w. Doc' w
langle Bool
b Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
equals Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
delev Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
rr) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
  SCase ZOX
zox Expr
e [CaseItem]
b MybStmt
s -> do
    Doc' ()
ex <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
e
    Doc' ()
dft <- case MybStmt
s of
      Attributed [] Maybe Statement
Nothing -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty
      MybStmt
_ -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' ()
"default:" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyMybStmt Bool
False MybStmt
s
    let
      pci :: CaseItem -> Reader PrintingOpts (Doc' ())
pci (CaseItem NonEmpty Expr
p MybStmt
v) = do
        Doc' ()
pat <- PrettyIdent (NonEmpty Expr)
-> NonEmpty Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent Expr
prettyExpr) NonEmpty Expr
p
        Doc' ()
branch <- Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyMybStmt Bool
False MybStmt
v
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
pat Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
branch
    Doc' ()
body <- (Doc' () -> Doc' () -> Doc' ())
-> (CaseItem -> Reader PrintingOpts (Doc' ()))
-> [CaseItem]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) CaseItem -> Reader PrintingOpts (Doc' ())
pci [CaseItem]
b
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
      Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block
        (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"case" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> case ZOX
zox of {ZOX
ZOXZ -> Doc' ()
"z"; ZOX
ZOXO -> Doc' ()
forall a. Monoid a => a
mempty; ZOX
ZOXX -> Doc' ()
"x"} Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
gpar Doc' ()
ex)
        Doc' ()
"endcase"
        (Doc' ()
body Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' ()
dft)
  SIf Expr
c MybStmt
t MybStmt
f -> do
    Doc' ()
head <- (Doc' ()
"if" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
c
    case MybStmt
f of
      Attributed [] Maybe Statement
Nothing | Bool
protect Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
False -> (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
False MybStmt
t
      Attributed [] (Just x :: Statement
x@(SBlock Maybe (Identifier, [AttrIded StdBlockDecl])
_ Bool
_ [AttrStmt]
_)) -> do
        -- `else` and `begin`/`fork` at same indentation level
        Doc' ()
tb <- Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
True MybStmt
t
        Doc' ()
fb <- Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
False Statement
x
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
tb) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' ()
"else" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
fb
      Attributed [] (Just x :: Statement
x@(SIf Expr
_ MybStmt
_ MybStmt
_)) -> do
        -- `if` and `else if` at same indentation level
        Doc' ()
tb <- Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
True MybStmt
t
        Doc' ()
fb <- Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
protect Statement
x
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
tb) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' ()
"else" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
fb
      MybStmt
_ -> do
        Doc' ()
tb <- Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
True MybStmt
t
        Doc' ()
fb <- Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
protect MybStmt
f
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
tb) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' ()
"else" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
fb)
  SDisable HierIdent
hi -> (\Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"disable" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent HierIdent -> HierIdent -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent HierIdent
prettyHierIdent HierIdent
hi
  SEventTrigger HierIdent
hi [Expr]
e -> do
    Doc' ()
dhi <- PrettyIdent HierIdent -> HierIdent -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent HierIdent
prettyHierIdent HierIdent
hi
    Doc' ()
dim <- (Doc' () -> Doc' () -> Doc' ())
-> (Expr -> Reader PrintingOpts (Doc' ()))
-> [Expr]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(</>) ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
brk) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Expr -> Reader PrintingOpts (Doc' ()))
-> Expr
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr) [Expr]
e
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"->" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
dhi Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
dim Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
  SLoop LoopStatement
ls AttrStmt
s -> do
    Doc' ()
head <- case LoopStatement
ls of
      LoopStatement
LSForever -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
"forever"
      LSRepeat Expr
e -> (Doc' ()
"repeat" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
e
      LSWhile Expr
e -> (Doc' ()
"while" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
e
      LSFor VarAssign
i Expr
c VarAssign
u -> do
        Doc' ()
di <- PrettyIdent VarAssign -> VarAssign -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent VarAssign
prettyVarAssign VarAssign
i
        Doc' ()
dc <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent Expr
prettyExpr Expr
c 
        Doc' ()
du <- PrettyIdent VarAssign -> VarAssign -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent VarAssign
prettyVarAssign VarAssign
u
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"for" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
gpar (Doc' ()
di Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
dc Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
du)
    Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> AttrStmt -> Reader PrintingOpts (Doc' ())
prettyAttrStmt Bool
protect AttrStmt
s
  SProcContAssign ProcContAssign
pca ->
    (Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case ProcContAssign
pca of
      PCAAssign VarAssign
va -> (Doc' ()
"assign" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent VarAssign -> VarAssign -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent VarAssign
prettyVarAssign VarAssign
va
      PCADeassign VarLValue
lv -> (Doc' ()
"deassign" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent VarLValue -> VarLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent VarLValue
prettyVarLV VarLValue
lv
      PCAForce Either VarAssign NetAssign
lv -> (Doc' ()
"force" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (VarAssign -> Reader PrintingOpts (Doc' ()))
-> (NetAssign -> Reader PrintingOpts (Doc' ()))
-> Either VarAssign NetAssign
-> Reader PrintingOpts (Doc' ())
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (PrettyIdent VarAssign -> VarAssign -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent VarAssign
prettyVarAssign) (PrettyIdent NetAssign -> NetAssign -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent NetAssign
prettyNetAssign) Either VarAssign NetAssign
lv
      PCARelease Either VarLValue NetLValue
lv -> (Doc' ()
"release" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (VarLValue -> Reader PrintingOpts (Doc' ()))
-> (NetLValue -> Reader PrintingOpts (Doc' ()))
-> Either VarLValue NetLValue
-> Reader PrintingOpts (Doc' ())
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (PrettyIdent VarLValue -> VarLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent VarLValue
prettyVarLV) (PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent NetLValue
prettyNetLV) Either VarLValue NetLValue
lv
  SProcTimingControl Either Delay1 EventControl
dec MybStmt
s -> do
    (Doc' (), Doc' ())
ddec <- PrettyIdent Delay1
-> PrettyIdent EventControl
-> Either Delay1 EventControl
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either PrettyIdent Delay1
prettyDelay1 PrettyIdent EventControl
prettyEventControl Either Delay1 EventControl
dec
    (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group ((Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
ddec) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyMybStmt Bool
protect MybStmt
s
  SBlock Maybe (Identifier, [AttrIded StdBlockDecl])
h Bool
ps [AttrStmt]
s -> do
    Doc' ()
head <- ((Identifier, [AttrIded StdBlockDecl])
 -> Reader PrintingOpts (Doc' ()))
-> Maybe (Identifier, [AttrIded StdBlockDecl])
-> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (\(Identifier
s, [AttrIded StdBlockDecl]
_) -> (Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
s) Maybe (Identifier, [AttrIded StdBlockDecl])
h
    Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block
      (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ (if Bool
ps then Doc' ()
"fork" else Doc' ()
"begin") Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?/> Doc' ()
head)
      (if Bool
ps then Doc' ()
"join" else Doc' ()
"end")
      (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<?#>) (((Identifier, [AttrIded StdBlockDecl])
 -> Reader PrintingOpts (Doc' ()))
-> Maybe (Identifier, [AttrIded StdBlockDecl])
-> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ([AttrIded StdBlockDecl] -> Reader PrintingOpts (Doc' ())
prettyStdBlockDecls ([AttrIded StdBlockDecl] -> Reader PrintingOpts (Doc' ()))
-> ((Identifier, [AttrIded StdBlockDecl])
    -> [AttrIded StdBlockDecl])
-> (Identifier, [AttrIded StdBlockDecl])
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Identifier, [AttrIded StdBlockDecl]) -> [AttrIded StdBlockDecl]
forall a b. (a, b) -> b
snd) Maybe (Identifier, [AttrIded StdBlockDecl])
h) ((Doc' () -> Doc' () -> Doc' ())
-> (AttrStmt -> Reader PrintingOpts (Doc' ()))
-> [AttrStmt]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) (Bool -> AttrStmt -> Reader PrintingOpts (Doc' ())
prettyAttrStmt Bool
False) [AttrStmt]
s)
  SSysTaskEnable ByteString
s [Maybe Expr]
a ->
    (\Doc' ()
x -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' ()
"$" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw ByteString
s Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
x) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (Maybe Expr)
-> [Maybe Expr] -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
pcslid (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> PrettyIdent Expr -> PrettyIdent (Maybe Expr)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (PrettyIdent (Doc' ())
mkid Doc' ()
forall a. Monoid a => a
mempty) PrettyIdent Expr
prettyExpr) [Maybe Expr]
a
  STaskEnable HierIdent
hi [Expr]
a -> do
    Doc' ()
dhi <- PrettyIdent HierIdent -> HierIdent -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent HierIdent
prettyHierIdent HierIdent
hi
    Doc' ()
args <- PrettyIdent Expr -> [Expr] -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
pcslid PrettyIdent Expr
prettyExpr [Expr]
a
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
dhi Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
args) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
  SWait Expr
e MybStmt
s -> PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
e Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
x -> (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' ()
"wait" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
gpar Doc' ()
x) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
protect MybStmt
s

prettyAttrStmt :: Bool -> AttrStmt -> Print
prettyAttrStmt :: Bool -> AttrStmt -> Reader PrintingOpts (Doc' ())
prettyAttrStmt Bool
protect (Attributed Attributes
a Statement
s) = Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
protect Statement
s

prettyMybStmt :: Bool -> MybStmt -> Print
prettyMybStmt :: Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyMybStmt Bool
protect (Attributed Attributes
a Maybe Statement
s) = case Maybe Statement
s of
  Maybe Statement
Nothing -> (Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Attributes
a
  Just Statement
s -> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
protect Statement
s

prettyRMybStmt :: Bool -> MybStmt -> Print
prettyRMybStmt :: Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyRMybStmt Bool
protect (Attributed Attributes
a Maybe Statement
s) = do
  Doc' ()
da <- case Attributes
a of {[] -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty; Attributes
_ -> (Doc' ()
forall w. Enum w => Doc' w
newline Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Attributes
a}
  Doc' ()
ds <- Reader PrintingOpts (Doc' ())
-> (Statement -> Reader PrintingOpts (Doc' ()))
-> Maybe Statement
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall w. Doc' w
semi) ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' ()
forall w. Enum w => Doc' w
newline Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Statement -> Reader PrintingOpts (Doc' ()))
-> Statement
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
protect) Maybe Statement
s
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
da Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
ds

prettyPortAssign :: PortAssign -> Print
prettyPortAssign :: PortAssign -> Reader PrintingOpts (Doc' ())
prettyPortAssign PortAssign
x = case PortAssign
x of
  PortPositional [Attributed (Maybe Expr)]
l ->
    Doc' ()
-> Doc' ()
-> PrettyIdent (Attributed (Maybe Expr))
-> [Attributed (Maybe Expr)]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
cslid
      Doc' ()
forall a. Monoid a => a
mempty
      Doc' ()
forall a. Monoid a => a
mempty
      ( \(Attributed Attributes
a Maybe Expr
e) -> case Maybe Expr
e of
          Maybe Expr
Nothing -> Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Attributes
a Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid
          Just Expr
e -> do
            (Doc' ()
i, Doc' ()
s) <- PrettyIdent Expr
prettyExpr Expr
e
            Doc' ()
d <- Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a Doc' ()
i
            (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
d, Doc' ()
s)
      )
      [Attributed (Maybe Expr)]
l
  PortNamed [AttrIded (Maybe Expr)]
l ->
    Doc' ()
-> Doc' ()
-> (AttrIded (Maybe Expr) -> Reader PrintingOpts (Doc' ()))
-> [AttrIded (Maybe Expr)]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
csl
      Doc' ()
forall a. Monoid a => a
mempty
      Doc' ()
forall w. Enum w => Doc' w
softline
      ( \(AttrIded Attributes
a Identifier
i Maybe Expr
e) -> do
          Doc' ()
s <- PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent Identifier
i
          Doc' ()
ex <- (Expr -> Reader PrintingOpts (Doc' ()))
-> Maybe Expr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr) Maybe Expr
e
          Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a (Doc' ()
forall w. Doc' w
dot Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
s Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar Doc' ()
ex)
      )
      [AttrIded (Maybe Expr)]
l

prettyModGenSingleItem :: ModGenSingleItem -> Bool -> Print
prettyModGenSingleItem :: ModGenSingleItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenSingleItem ModGenSingleItem
x Bool
protect = case ModGenSingleItem
x of
  MGINetInit NetType
nt DriveStrength
ds NetProp
np NonEmpty NetInit
l ->
    NetProp -> Reader PrintingOpts (Doc' ())
com NetProp
np Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
d -> Doc' ()
-> PrettyIdent NetInit
-> NonEmpty NetInit
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (NetType -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow NetType
nt Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d) PrettyIdent NetInit
pide NonEmpty NetInit
l
  MGINetDecl NetType
nt NetProp
np NonEmpty NetDecl
l -> NetProp -> Reader PrintingOpts (Doc' ())
com NetProp
np Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
d -> Doc' ()
-> PrettyIdent NetDecl
-> NonEmpty NetDecl
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (NetType -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow NetType
nt Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d) PrettyIdent NetDecl
pidd NonEmpty NetDecl
l
  MGITriD DriveStrength
ds NetProp
np NonEmpty NetInit
l ->
    NetProp -> Reader PrintingOpts (Doc' ())
com NetProp
np Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
d -> Doc' ()
-> PrettyIdent NetInit
-> NonEmpty NetInit
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (Doc' ()
"trireg" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d) PrettyIdent NetInit
pide NonEmpty NetInit
l
  MGITriC ChargeStrength
cs NetProp
np NonEmpty NetDecl
l ->
    NetProp -> Reader PrintingOpts (Doc' ())
com NetProp
np Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
d -> Doc' ()
-> PrettyIdent NetDecl
-> NonEmpty NetDecl
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (Doc' ()
"trireg" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' () -> Bool -> Doc' ()
piff (ChargeStrength -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow ChargeStrength
cs) (ChargeStrength
cs ChargeStrength -> ChargeStrength -> Bool
forall a. Eq a => a -> a -> Bool
== ChargeStrength
CSMedium) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d) PrettyIdent NetDecl
pidd NonEmpty NetDecl
l
  MGIBlockDecl BlockDecl (Compose NonEmpty Identified) EDI
bd -> AllBlockDecl -> Reader PrintingOpts (Doc' ())
prettyAllBlockDecl (AllBlockDecl -> Reader PrintingOpts (Doc' ()))
-> AllBlockDecl -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ (forall x.
 Compose NonEmpty Identified x -> NonEmpty (Identified x))
-> (EDI -> EDI)
-> BlockDecl (Compose NonEmpty Identified) EDI
-> AllBlockDecl
forall (f :: * -> *) t.
(forall x. f x -> NonEmpty (Identified x))
-> (t -> EDI) -> BlockDecl f t -> AllBlockDecl
fromBlockDecl Compose NonEmpty Identified x -> NonEmpty (Identified x)
forall x. Compose NonEmpty Identified x -> NonEmpty (Identified x)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose EDI -> EDI
forall a. a -> a
id BlockDecl (Compose NonEmpty Identified) EDI
bd
  MGIGenVar NonEmpty Identifier
l -> Doc' ()
-> PrettyIdent Identifier
-> NonEmpty Identifier
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
"genvar" PrettyIdent Identifier
prettyIdent NonEmpty Identifier
l
  MGITask Bool
aut Identifier
s [AttrIded (TFBlockDecl Dir)]
d MybStmt
b -> do
    Doc' ()
i <- PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent Identifier
s
    Doc' ()
decls <- (Dir -> Dir)
-> [AttrIded (TFBlockDecl Dir)] -> Reader PrintingOpts (Doc' ())
forall d.
(d -> Dir)
-> [AttrIded (TFBlockDecl d)] -> Reader PrintingOpts (Doc' ())
prettyTFBlockDecls Dir -> Dir
forall a. a -> a
id [AttrIded (TFBlockDecl Dir)]
d
    Doc' ()
body <- Bool -> MybStmt -> Reader PrintingOpts (Doc' ())
prettyMybStmt Bool
False MybStmt
b
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
      Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
"task" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Bool -> Doc' ()
mauto Bool
aut) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) Doc' ()
"endtask" (Doc' ()
decls Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest Doc' ()
body)
  MGIFunc Bool
aut Maybe (ComType ())
t Identifier
s [AttrIded (TFBlockDecl ())]
d FunctionStatement
b -> do
    Doc' ()
dt <- (ComType () -> Reader PrintingOpts (Doc' ()))
-> Maybe (ComType ()) -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((() -> Doc' ()) -> ComType () -> Reader PrintingOpts (Doc' ())
forall d.
(d -> Doc' ()) -> ComType d -> Reader PrintingOpts (Doc' ())
prettyComType ((() -> Doc' ()) -> ComType () -> Reader PrintingOpts (Doc' ()))
-> (() -> Doc' ()) -> ComType () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> () -> Doc' ()
forall a b. a -> b -> a
const Doc' ()
forall a. Monoid a => a
mempty) Maybe (ComType ())
t
    Doc' ()
i <- PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent Identifier
s
    Doc' ()
decls <- (() -> Dir)
-> [AttrIded (TFBlockDecl ())] -> Reader PrintingOpts (Doc' ())
forall d.
(d -> Dir)
-> [AttrIded (TFBlockDecl d)] -> Reader PrintingOpts (Doc' ())
prettyTFBlockDecls (Dir -> () -> Dir
forall a b. a -> b -> a
const Dir
DirIn) [AttrIded (TFBlockDecl ())]
d
    Doc' ()
body <- Bool -> Statement -> Reader PrintingOpts (Doc' ())
prettyStatement Bool
False (Statement -> Reader PrintingOpts (Doc' ()))
-> Statement -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ FunctionStatement -> Statement
toStatement FunctionStatement
b
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
      Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block
        (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
"function" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Bool -> Doc' ()
mauto Bool
aut Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dt) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi)
        Doc' ()
"endfunction"
        (Doc' ()
decls Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest Doc' ()
body)
  MGIDefParam NonEmpty ParamOver
l ->
    Doc' ()
-> PrettyIdent ParamOver
-> NonEmpty ParamOver
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid
      Doc' ()
"defparam"
      (\(ParamOver HierIdent
hi CMinTypMax
v) -> ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ((Doc' (), Doc' ()) -> Doc' ())
-> (Doc' (), Doc' ())
-> (Doc' (), Doc' ())
-> (Doc' (), Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst) (PrettyIdent HierIdent
prettyHierIdent HierIdent
hi) (PrettyIdent CMinTypMax
prettyCMTM CMinTypMax
v))
      NonEmpty ParamOver
l
  MGIContAss DriveStrength
ds Maybe Delay3
d3 NonEmpty NetAssign
l -> do
    Doc' ()
d <- (Delay3 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay3 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay3 -> Delay3 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay3
prettyDelay3) Maybe Delay3
d3
    Doc' ()
-> PrettyIdent NetAssign
-> NonEmpty NetAssign
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (Doc' ()
"assign" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d) PrettyIdent NetAssign
prettyNetAssign NonEmpty NetAssign
l
  MGICMos Bool
r Maybe Delay3
d3 NonEmpty GICMos
l -> do
    Doc' ()
d <- (Delay3 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay3 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay3 -> Delay3 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay3
prettyDelay3) Maybe Delay3
d3
    Doc' ()
-> (GICMos -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GICMos
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' () -> Bool -> Doc' ()
pift Doc' ()
"r" Bool
r Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"cmos" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d)
      ( \(GICMos Maybe InstanceName
n NetLValue
lv Expr
inp Expr
nc Expr
pc) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dlv <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv
          Doc' ()
di <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
inp
          Doc' ()
dn <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
nc
          Doc' ()
dp <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
pc
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
di Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dn Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dp)
      )
      NonEmpty GICMos
l
  MGIEnable Bool
r Bool
oz DriveStrength
ds Maybe Delay3
d3 NonEmpty GIEnable
l -> do
    Doc' ()
d <- (Delay3 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay3 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay3 -> Delay3 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay3
prettyDelay3) Maybe Delay3
d3
    Doc' ()
-> (GIEnable -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GIEnable
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      ( (if Bool
r then Doc' ()
"not" else Doc' ()
"buf") Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"if" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (if Bool
oz then Doc' ()
"1" else Doc' ()
"0")
          Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds
          Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d
      )
      ( \(GIEnable Maybe InstanceName
n NetLValue
lv Expr
inp Expr
e) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dlv <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv
          Doc' ()
di <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
inp
          Doc' ()
de <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
e
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
di Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
de)
      )
      NonEmpty GIEnable
l
  MGIMos Bool
r Bool
np Maybe Delay3
d3 NonEmpty GIMos
l -> do
    Doc' ()
d <- (Delay3 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay3 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay3 -> Delay3 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay3
prettyDelay3) Maybe Delay3
d3
    Doc' ()
-> (GIMos -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GIMos
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' () -> Bool -> Doc' ()
pift Doc' ()
"r" Bool
r Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (if Bool
np then Doc' ()
"n" else Doc' ()
"p") Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"mos" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d)
      ( \(GIMos Maybe InstanceName
n NetLValue
lv Expr
inp Expr
e) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dlv <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv
          Doc' ()
di <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
inp
          Doc' ()
de <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
e
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
di Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
de)
      )
      NonEmpty GIMos
l
  MGINIn NInputType
nin Bool
n DriveStrength
ds Maybe Delay2
d2 NonEmpty GINIn
l -> do
    Doc' ()
d <- (Delay2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay2 -> Delay2 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay2
prettyDelay2) Maybe Delay2
d2
    Doc' ()
-> (GINIn -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GINIn
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      ( (if NInputType
nin NInputType -> NInputType -> Bool
forall a. Eq a => a -> a -> Bool
== NInputType
NITXor then Doc' ()
"x" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Bool -> Doc' ()
pift Doc' ()
"n" Bool
n Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"or" else Doc' () -> Bool -> Doc' ()
pift Doc' ()
"n" Bool
n Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> NInputType -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow NInputType
nin)
          Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds
          Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d
      )
      ( \(GINIn Maybe InstanceName
n NetLValue
lv NonEmpty Expr
inp) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dlv <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv
          Doc' ()
di <- PrettyIdent (NonEmpty Expr)
-> NonEmpty Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr))
-> PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a b. (a -> b) -> a -> b
$ PrettyIdent Expr -> PrettyIdent Expr
forall x. PrettyIdent x -> PrettyIdent x
mkng PrettyIdent Expr
prettyExpr) NonEmpty Expr
inp
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
di)
      )
      NonEmpty GINIn
l
  MGINOut Bool
r DriveStrength
ds Maybe Delay2
d2 NonEmpty GINOut
l -> do
    Doc' ()
d <- (Delay2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay2 -> Delay2 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay2
prettyDelay2) Maybe Delay2
d2
    Doc' ()
-> (GINOut -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GINOut
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      ((if Bool
r then Doc' ()
"not" else Doc' ()
"buf") Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d)
      ( \(GINOut Maybe InstanceName
n NonEmpty NetLValue
lv Expr
inp) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dlv <- PrettyIdent (NonEmpty NetLValue)
-> NonEmpty NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent NetLValue -> PrettyIdent (NonEmpty NetLValue)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent NetLValue -> PrettyIdent (NonEmpty NetLValue))
-> PrettyIdent NetLValue -> PrettyIdent (NonEmpty NetLValue)
forall a b. (a -> b) -> a -> b
$ PrettyIdent NetLValue -> PrettyIdent NetLValue
forall x. PrettyIdent x -> PrettyIdent x
mkng PrettyIdent NetLValue
prettyNetLV) NonEmpty NetLValue
lv
          Doc' ()
di <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
inp
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
di)
      )
      NonEmpty GINOut
l
  MGIPassEn Bool
r Bool
oz Maybe Delay2
d2 NonEmpty GIPassEn
l -> do
    Doc' ()
d <- (Delay2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay2 -> Delay2 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay2
prettyDelay2) Maybe Delay2
d2
    Doc' ()
-> (GIPassEn -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GIPassEn
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' () -> Bool -> Doc' ()
pift Doc' ()
"r" Bool
r Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"tranif" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (if Bool
oz then Doc' ()
"1" else Doc' ()
"0") Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d)
      ( \(GIPassEn Maybe InstanceName
n NetLValue
ll NetLValue
rl Expr
e) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dll <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
ll
          Doc' ()
drl <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
rl
          Doc' ()
de <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent Expr
prettyExpr Expr
e
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dll Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
drl Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
de)
      )
      NonEmpty GIPassEn
l
  MGIPass Bool
r NonEmpty GIPass
l ->
    Doc' ()
-> (GIPass -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GIPass
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' () -> Bool -> Doc' ()
pift Doc' ()
"r" Bool
r Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"tran")
      ( \(GIPass Maybe InstanceName
n NetLValue
ll NetLValue
rl) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dll <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
ll
          Doc' ()
drl <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent NetLValue
prettyNetLV NetLValue
rl
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dll Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
drl))
      NonEmpty GIPass
l
  MGIPull Bool
ud DriveStrength
ds NonEmpty GIPull
l ->
    Doc' ()
-> (GIPull -> Reader PrintingOpts (Doc' ()))
-> NonEmpty GIPull
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' ()
"pull" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (if Bool
ud then Doc' ()
"up" else Doc' ()
"down") Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds)
      (\(GIPull Maybe InstanceName
n NetLValue
lv) -> (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
i -> (Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv)
      NonEmpty GIPull
l
  MGIUDPInst Identifier
kind DriveStrength
ds Maybe Delay2
d2 NonEmpty UDPInst
l -> do
    Doc' ()
d <- (Delay2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay2 -> Delay2 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay2
prettyDelay2) Maybe Delay2
d2
    Doc' ()
dk <- Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
kind
    Doc' ()
-> (UDPInst -> Reader PrintingOpts (Doc' ()))
-> NonEmpty UDPInst
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' ()
dk Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> DriveStrength -> Doc' ()
prettyDriveStrength DriveStrength
ds Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d)
      ( \(UDPInst Maybe InstanceName
n NetLValue
lv NonEmpty Expr
args) -> do
          Doc' ()
i <- (InstanceName -> Reader PrintingOpts (Doc' ()))
-> Maybe InstanceName -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm InstanceName -> Reader PrintingOpts (Doc' ())
pname Maybe InstanceName
n
          Doc' ()
dlv <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv
          Doc' ()
da <- PrettyIdent (NonEmpty Expr)
-> NonEmpty Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr))
-> PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a b. (a -> b) -> a -> b
$ PrettyIdent Expr -> PrettyIdent Expr
forall x. PrettyIdent x -> PrettyIdent x
mkg PrettyIdent Expr
prettyExpr) NonEmpty Expr
args
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
da)
      )
      NonEmpty UDPInst
l
  MGIModInst Identifier
kind ParamAssign
param NonEmpty ModInst
l -> do
    Doc' ()
dp <- case ParamAssign
param of
      ParamPositional [Expr]
l -> Doc' ()
-> Doc' ()
-> PrettyIdent Expr
-> [Expr]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
cslid (Doc' ()
"#(" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
softspace) Doc' ()
forall w. Doc' w
rparen (PrettyIdent Expr -> PrettyIdent Expr
forall x. PrettyIdent x -> PrettyIdent x
mkng PrettyIdent Expr
prettyExpr) [Expr]
l
      ParamNamed [Identified (Maybe MinTypMax)]
l ->
        Doc' ()
-> Doc' ()
-> (Identified (Maybe MinTypMax) -> Reader PrintingOpts (Doc' ()))
-> [Identified (Maybe MinTypMax)]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
csl
          (Doc' ()
"#(" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
softspace)
          (Doc' ()
forall w. Enum w => Doc' w
softline Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
rparen)
          ( \(Identified Identifier
i Maybe MinTypMax
e) -> do
              Doc' ()
s <- PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent Identifier
i
              Doc' ()
d <- (MinTypMax -> Reader PrintingOpts (Doc' ()))
-> Maybe MinTypMax -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent MinTypMax
prettyMTM) Maybe MinTypMax
e
              Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
forall w. Doc' w
dot Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
s Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar Doc' ()
d
          )
          [Identified (Maybe MinTypMax)]
l
    Doc' ()
dk <- Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
kind
    Doc' ()
-> (ModInst -> Reader PrintingOpts (Doc' ()))
-> NonEmpty ModInst
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' ()
dk Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dp)
      (\(ModInst InstanceName
n PortAssign
args) -> InstanceName -> Reader PrintingOpts (Doc' ())
pname InstanceName
n Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
i -> (Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PortAssign -> Reader PrintingOpts (Doc' ())
prettyPortAssign PortAssign
args)
      NonEmpty ModInst
l
  MGIUnknownInst Identifier
kind Maybe (Either Expr (Expr, Expr))
param NonEmpty UknInst
l -> do
    Doc' ()
dp <- case Maybe (Either Expr (Expr, Expr))
param of
      Maybe (Either Expr (Expr, Expr))
Nothing -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty
      Just (Left Expr
e) -> (Doc' ()
"#" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
e
      Just (Right (Expr
e0, Expr
e1)) ->
        (Doc' ()
"#" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
par (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
(<.>) (PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent Expr
prettyExpr Expr
e0) (PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent Expr
prettyExpr Expr
e1)
    Doc' ()
dk <- Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
kind
    Doc' ()
-> (UknInst -> Reader PrintingOpts (Doc' ()))
-> NonEmpty UknInst
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> (a -> Reader PrintingOpts (Doc' ()))
-> NonEmpty a
-> Reader PrintingOpts (Doc' ())
prettyItems
      (Doc' ()
dk Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dp)
      ( \(UknInst InstanceName
n NetLValue
lv NonEmpty Expr
args) -> do
          Doc' ()
i <- InstanceName -> Reader PrintingOpts (Doc' ())
pname InstanceName
n
          Doc' ()
dlv <- PrettyIdent NetLValue -> NetLValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent NetLValue
prettyNetLV NetLValue
lv
          Doc' ()
da <- PrettyIdent (NonEmpty Expr)
-> NonEmpty Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent Expr -> PrettyIdent (NonEmpty Expr))
-> PrettyIdent Expr -> PrettyIdent (NonEmpty Expr)
forall a b. (a -> b) -> a -> b
$ PrettyIdent Expr -> PrettyIdent Expr
forall x. PrettyIdent x -> PrettyIdent x
mkg PrettyIdent Expr
prettyExpr) NonEmpty Expr
args
          Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
i Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
dlv Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
da)
      )
      NonEmpty UknInst
l
  MGIInitial AttrStmt
s -> (Doc' ()
"initial" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> AttrStmt -> Reader PrintingOpts (Doc' ())
prettyAttrStmt Bool
protect AttrStmt
s
  MGIAlways AttrStmt
s -> (Doc' ()
"always" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> AttrStmt -> Reader PrintingOpts (Doc' ())
prettyAttrStmt Bool
protect AttrStmt
s
  MGILoopGen Identifier
si CExpr
vi CExpr
cond Identifier
su CExpr
vu (Identified (Identifier ByteString
s) [Attributed ModGenBlockedItem]
i) -> do
    Doc' ()
di <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj ((Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
si) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> PrettyIdent CExpr -> PrettyIdent CExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent CExpr
prettyCExpr) CExpr
vi
    Doc' ()
dc <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent CExpr
prettyCExpr CExpr
cond
    Doc' ()
du <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj ((Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
su) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> PrettyIdent CExpr -> PrettyIdent CExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent CExpr
prettyCExpr) CExpr
vu
    let head :: Doc' ()
head = Doc' ()
"for" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
gpar (Doc' ()
di Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
dc Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
du)
    case [Attributed ModGenBlockedItem] -> [Attributed ModGenSingleItem]
fromMGBlockedItem [Attributed ModGenBlockedItem]
i of
      [Attributed Attributes
a ModGenSingleItem
x] | ByteString -> Bool
B.null ByteString
s ->
        Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (ModGenSingleItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenSingleItem ModGenSingleItem
x Bool
protect)
      [Attributed ModGenSingleItem]
r -> (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Identifier
-> [Attributed ModGenSingleItem] -> Reader PrintingOpts (Doc' ())
prettyGBlock (ByteString -> Identifier
Identifier ByteString
s) [Attributed ModGenSingleItem]
r
  MGICondItem ModGenCondItem
ci -> ModGenCondItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenCondItem ModGenCondItem
ci Bool
protect -- protect should never be True in practice
  where
    pname :: InstanceName -> Reader PrintingOpts (Doc' ())
pname (InstanceName Identifier
i Maybe Range2
r) = (Range2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Range2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2 Maybe Range2
r Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
rng -> PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj (PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent Doc' ()
rng) Identifier
i
    mauto :: Bool -> Doc' ()
mauto Bool
b = Doc' () -> Bool -> Doc' ()
pift Doc' ()
"automatic" Bool
b
    pidd :: PrettyIdent NetDecl
pidd (NetDecl Identifier
i [Range2]
d) = [Range2] -> Reader PrintingOpts (Doc' ())
prettyR2s [Range2]
d Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
dim -> PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent Doc' ()
dim Identifier
i
    pide :: PrettyIdent NetInit
pide (NetInit Identifier
i Expr
e) = (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
i) (PrettyIdent Expr
prettyExpr Expr
e)
    com :: NetProp -> Reader PrintingOpts (Doc' ())
com (NetProp Bool
b Maybe (Maybe Bool, Range2)
vs Maybe Delay3
d3) = do
      let s :: Doc' ()
s = Doc' () -> Bool -> Doc' ()
pift Doc' ()
"signed" Bool
b
      Doc' ()
dvs <- Reader PrintingOpts (Doc' ())
-> ((Maybe Bool, Range2) -> Reader PrintingOpts (Doc' ()))
-> Maybe (Maybe Bool, Range2)
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
        (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
s)
        ( \(Maybe Bool
vs, Range2
r2) ->
            (\Doc' ()
x -> Doc' () -> (Bool -> Doc' ()) -> Maybe Bool -> Doc' ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc' ()
forall a. Monoid a => a
mempty (\Bool
b -> if Bool
b then Doc' ()
"vectored" else Doc' ()
"scalared") Maybe Bool
vs Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
s Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
x)
              (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2 Range2
r2
        )
        Maybe (Maybe Bool, Range2)
vs
      (Doc' ()
dvs Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Delay3 -> Reader PrintingOpts (Doc' ()))
-> Maybe Delay3 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Delay3 -> Delay3 -> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Delay3
prettyDelay3) Maybe Delay3
d3

-- | Nested conditionals with dangling else support
prettyModGenCondItem :: ModGenCondItem -> Bool -> Print
prettyModGenCondItem :: ModGenCondItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenCondItem ModGenCondItem
ci Bool
protect = case ModGenCondItem
ci of
  MGCIIf CExpr
c GenerateCondBlock
t GenerateCondBlock
f -> do
    Doc' ()
head <- (Doc' ()
"if" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent CExpr
prettyCExpr CExpr
c
    case GenerateCondBlock
f of
      GenerateCondBlock
GCBEmpty -> (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' () -> Bool -> Doc' ()
pift Doc' ()
"else;" Bool
protect) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Doc' ()
-> Bool -> GenerateCondBlock -> Reader PrintingOpts (Doc' ())
pGCB Doc' ()
head Bool
protect GenerateCondBlock
t
      GenerateCondBlock
_ -> (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) (Doc' ()
-> Bool -> GenerateCondBlock -> Reader PrintingOpts (Doc' ())
pGCB Doc' ()
head Bool
True GenerateCondBlock
t) (Doc' ()
-> Bool -> GenerateCondBlock -> Reader PrintingOpts (Doc' ())
pGCB Doc' ()
"else" Bool
protect GenerateCondBlock
f)
  MGCICase CExpr
c [GenCaseItem]
b GenerateCondBlock
md -> do
    Doc' ()
dc <- PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent CExpr
prettyCExpr CExpr
c
    Doc' ()
body <-
      (Doc' () -> Doc' () -> Doc' ())
-> (GenCaseItem -> Reader PrintingOpts (Doc' ()))
-> [GenCaseItem]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl
        Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>)
        (\(GenCaseItem NonEmpty CExpr
p GenerateCondBlock
v) -> PrettyIdent (NonEmpty CExpr)
-> NonEmpty CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj (PrettyIdent CExpr -> PrettyIdent (NonEmpty CExpr)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent CExpr
prettyCExpr) NonEmpty CExpr
p Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
pat -> Doc' ()
-> Bool -> GenerateCondBlock -> Reader PrintingOpts (Doc' ())
pGCB (Doc' ()
pat Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon) Bool
False GenerateCondBlock
v)
        [GenCaseItem]
b
    Doc' ()
dd <- case GenerateCondBlock
md of GenerateCondBlock
GCBEmpty -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty; GenerateCondBlock
_ -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Doc' ()
-> Bool -> GenerateCondBlock -> Reader PrintingOpts (Doc' ())
pGCB Doc' ()
"default:" Bool
False GenerateCondBlock
md
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"case" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
gpar Doc' ()
dc) Doc' ()
"endcase" (Doc' ()
body Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' ()
dd)
  where
    isNotCond :: ModGenItem f -> Bool
isNotCond ModGenItem f
x = case ModGenItem f
x of MGICondItem ModGenCondItem
_ -> Bool
False; ModGenItem f
_ -> Bool
True
    pGCB :: Doc' ()
-> Bool -> GenerateCondBlock -> Reader PrintingOpts (Doc' ())
pGCB Doc' ()
head Bool
p GenerateCondBlock
b = case GenerateCondBlock
b of
      GenerateCondBlock
GCBEmpty -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
      GCBConditional (Attributed Attributes
a ModGenCondItem
ci) ->
        Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (ModGenCondItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenCondItem ModGenCondItem
ci Bool
p)
      GCBBlock (Identified (Identifier ByteString
s) [Attributed ModGenBlockedItem]
r) -> case [Attributed ModGenBlockedItem] -> [Attributed ModGenSingleItem]
fromMGBlockedItem [Attributed ModGenBlockedItem]
r of
        [Attributed Attributes
a ModGenSingleItem
x] | ByteString -> Bool
B.null ByteString
s Bool -> Bool -> Bool
&& ModGenSingleItem -> Bool
forall {f :: * -> *}. ModGenItem f -> Bool
isNotCond ModGenSingleItem
x ->
          Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (ModGenSingleItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenSingleItem ModGenSingleItem
x Bool
protect)
        [Attributed ModGenSingleItem]
r -> (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Identifier
-> [Attributed ModGenSingleItem] -> Reader PrintingOpts (Doc' ())
prettyGBlock (ByteString -> Identifier
Identifier ByteString
s) [Attributed ModGenSingleItem]
r

-- | Generate block
prettyGBlock :: Identifier -> [Attributed ModGenSingleItem] -> Print
prettyGBlock :: Identifier
-> [Attributed ModGenSingleItem] -> Reader PrintingOpts (Doc' ())
prettyGBlock Identifier
i [Attributed ModGenSingleItem]
l = do
  Doc' ()
bn <- Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
i
  Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block (Doc' ()
"begin" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Bool -> Doc' ()
piff (Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
bn) (Doc' () -> Bool
forall w. Doc' w -> Bool
nullDoc Doc' ()
bn)) Doc' ()
"end"
    (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> (Attributed ModGenSingleItem -> Reader PrintingOpts (Doc' ()))
-> [Attributed ModGenSingleItem]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl
      Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>)
      (\(Attributed Attributes
a ModGenSingleItem
x) -> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ModGenSingleItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenSingleItem ModGenSingleItem
x Bool
False)
      [Attributed ModGenSingleItem]
l

prettyGenerateBlock :: GenerateBlock -> Print
prettyGenerateBlock :: Identified [Attributed ModGenBlockedItem]
-> Reader PrintingOpts (Doc' ())
prettyGenerateBlock (Identified Identifier
s [Attributed ModGenBlockedItem]
x) = Identifier
-> [Attributed ModGenSingleItem] -> Reader PrintingOpts (Doc' ())
prettyGBlock Identifier
s ([Attributed ModGenSingleItem] -> Reader PrintingOpts (Doc' ()))
-> [Attributed ModGenSingleItem] -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ [Attributed ModGenBlockedItem] -> [Attributed ModGenSingleItem]
fromMGBlockedItem [Attributed ModGenBlockedItem]
x

prettySpecParams :: Maybe Range2 -> NonEmpty SpecParamDecl -> Print
prettySpecParams :: Maybe Range2
-> NonEmpty SpecParamDecl -> Reader PrintingOpts (Doc' ())
prettySpecParams Maybe Range2
rng NonEmpty SpecParamDecl
l = do
  Doc' ()
dr <- (Range2 -> Reader PrintingOpts (Doc' ()))
-> Maybe Range2 -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm Range2 -> Reader PrintingOpts (Doc' ())
prettyRange2 Maybe Range2
rng
  Doc' ()
-> PrettyIdent SpecParamDecl
-> NonEmpty SpecParamDecl
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid
    (Doc' ()
"specparam" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dr)
    ( \SpecParamDecl
d -> case SpecParamDecl
d of
        SPDAssign Identifier
i CMinTypMax
v -> (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Identifier -> Reader PrintingOpts (Doc' ())
rawId Identifier
i) (PrettyIdent CMinTypMax
prettyCMTM CMinTypMax
v)
        SPDPathPulse Maybe (SpecTerm, SpecTerm)
io CMinTypMax
r CMinTypMax
e -> do
          Doc' ()
dpp <- ((SpecTerm, SpecTerm) -> Reader PrintingOpts (Doc' ()))
-> Maybe (SpecTerm, SpecTerm) -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (SpecTerm, SpecTerm) -> Reader PrintingOpts (Doc' ())
pPP Maybe (SpecTerm, SpecTerm)
io
          Doc' ()
dr <- PrettyIdent CMinTypMax
-> CMinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent CMinTypMax
prettyCMTM CMinTypMax
r
          Doc' ()
de <- if CMinTypMax
r CMinTypMax -> CMinTypMax -> Bool
forall a. Eq a => a -> a -> Bool
== CMinTypMax
e then Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty else (Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent CMinTypMax
-> CMinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent CMinTypMax
prettyCMTM CMinTypMax
e
          Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq (Doc' ()
"PATHPULSE$" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
dpp) ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (Doc' ())
mkid (Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
dr Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
de)
    )
    NonEmpty SpecParamDecl
l
  where
    -- Change to a spaced layout if tools allow it
    pPP :: (SpecTerm, SpecTerm) -> Reader PrintingOpts (Doc' ())
pPP (SpecTerm
i, SpecTerm
o) = do
      Doc' ()
din <- PrettyIdent SpecTerm -> SpecTerm -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent SpecTerm
prettySpecTerm SpecTerm
i
      (Doc' (), Doc' ())
dout <- PrettyIdent SpecTerm
prettySpecTerm SpecTerm
o
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
din Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
"$" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
dout

prettyPathDecl :: SpecPath -> Maybe Bool -> Maybe (Expr, Maybe Bool) -> Print
prettyPathDecl :: SpecPath
-> Maybe Bool
-> Maybe (Expr, Maybe Bool)
-> Reader PrintingOpts (Doc' ())
prettyPathDecl SpecPath
p Maybe Bool
pol Maybe (Expr, Maybe Bool)
eds = do
  -- parallel or full, source(s), destination(s)
  (Bool
pf, (Doc' ()
cin, Doc' ()
_), Doc' ()
cout) <- case SpecPath
p of
    SPParallel SpecTerm
i SpecTerm
o -> do
      (Doc' (), Doc' ())
sti <- PrettyIdent SpecTerm
prettySpecTerm SpecTerm
i
      (Doc' (), Doc' ())
sto <- PrettyIdent SpecTerm
prettySpecTerm SpecTerm
o
      (Bool, (Doc' (), Doc' ()), Doc' ())
-> ReaderT
     PrintingOpts Identity (Bool, (Doc' (), Doc' ()), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
True, (Doc' (), Doc' ())
sti, (Doc' (), Doc' ()) -> Doc' ()
fne (Doc' (), Doc' ())
sto)
    SPFull NonEmpty SpecTerm
i NonEmpty SpecTerm
o -> do
      (Doc' (), Doc' ())
sti <- PrettyIdent (NonEmpty SpecTerm)
ppSTs NonEmpty SpecTerm
i
      (Doc' (), Doc' ())
sto <- PrettyIdent (NonEmpty SpecTerm)
ppSTs NonEmpty SpecTerm
o
      (Bool, (Doc' (), Doc' ()), Doc' ())
-> ReaderT
     PrintingOpts Identity (Bool, (Doc' (), Doc' ()), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
False, (Doc' (), Doc' ())
sti, (Doc' (), Doc' ()) -> Doc' ()
fne (Doc' (), Doc' ())
sto)
  (Doc' ()
de, Doc' ()
ed) <- case Maybe (Expr, Maybe Bool)
eds of
    Maybe (Expr, Maybe Bool)
Nothing -> (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' ()
cout, Doc' ()
forall a. Monoid a => a
mempty)
    Just (Expr
dst, Maybe Bool
me) -> do
      Doc' ()
d <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Expr
prettyExpr Expr
dst
      (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return
        ( Doc' () -> Doc' ()
par (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
cout Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
po Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
d,
          Doc' () -> (Bool -> Doc' ()) -> Maybe Bool -> Doc' ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc' ()
forall a. Monoid a => a
mempty (\Bool
e -> if Bool
e then Doc' ()
"posedge" else Doc' ()
"negedge") Maybe Bool
me
        )
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' ()
ed Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group Doc' ()
cin) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Bool -> Doc' ()
pift Doc' ()
po Bool
noedge Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (if Bool
pf then Doc' ()
"=>" else Doc' ()
"*>") Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
de
  where
    ppSTs :: PrettyIdent (NonEmpty SpecTerm)
ppSTs = PrettyIdent SpecTerm -> PrettyIdent (NonEmpty SpecTerm)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 (PrettyIdent SpecTerm -> PrettyIdent (NonEmpty SpecTerm))
-> PrettyIdent SpecTerm -> PrettyIdent (NonEmpty SpecTerm)
forall a b. (a -> b) -> a -> b
$ PrettyIdent SpecTerm -> PrettyIdent SpecTerm
forall x. PrettyIdent x -> PrettyIdent x
mkng PrettyIdent SpecTerm
prettySpecTerm
    -- polarity
    po :: Doc' ()
po = Doc' () -> (Bool -> Doc' ()) -> Maybe Bool -> Doc' ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc' ()
forall a. Monoid a => a
mempty (\Bool
p -> if Bool
p then Doc' ()
"+" else Doc' ()
"-") Maybe Bool
pol
    -- edge sensitive path polarity isn't at the same place as non edge sensitive
    noedge :: Bool
noedge = Maybe (Expr, Maybe Bool)
eds Maybe (Expr, Maybe Bool) -> Maybe (Expr, Maybe Bool) -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe (Expr, Maybe Bool)
forall a. Maybe a
Nothing
    fne :: (Doc' (), Doc' ()) -> Doc' ()
fne = if Bool
noedge then (Doc' () -> Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> Doc' ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
(<>) else \(Doc' (), Doc' ())
x -> (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Enum w => Doc' w
newline

prettySpecifyItem :: SpecifySingleItem -> Print
prettySpecifyItem :: SpecifySingleItem -> Reader PrintingOpts (Doc' ())
prettySpecifyItem SpecifySingleItem
x =
  Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case SpecifySingleItem
x of
    SISpecParam Maybe Range2
r NonEmpty SpecParamDecl
l -> Maybe Range2
-> NonEmpty SpecParamDecl -> Reader PrintingOpts (Doc' ())
prettySpecParams Maybe Range2
r NonEmpty SpecParamDecl
l
    SIPulsestyleOnevent NonEmpty SpecTerm
o -> Doc' ()
-> PrettyIdent SpecTerm
-> NonEmpty SpecTerm
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
"pulsestyle_onevent" PrettyIdent SpecTerm
prettySpecTerm NonEmpty SpecTerm
o
    SIPulsestyleOndetect NonEmpty SpecTerm
o -> Doc' ()
-> PrettyIdent SpecTerm
-> NonEmpty SpecTerm
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
"pulsestyle_ondetect" PrettyIdent SpecTerm
prettySpecTerm NonEmpty SpecTerm
o
    SIShowcancelled NonEmpty SpecTerm
o -> Doc' ()
-> PrettyIdent SpecTerm
-> NonEmpty SpecTerm
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
"showcancelled" PrettyIdent SpecTerm
prettySpecTerm NonEmpty SpecTerm
o
    SINoshowcancelled NonEmpty SpecTerm
o -> Doc' ()
-> PrettyIdent SpecTerm
-> NonEmpty SpecTerm
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid Doc' ()
"noshowcancelled" PrettyIdent SpecTerm
prettySpecTerm NonEmpty SpecTerm
o
    SIPathDeclaration ModulePathCondition
mpc SpecPath
p Maybe Bool
pol Maybe (Expr, Maybe Bool)
eds PathDelayValue
l -> do
      Doc' ()
dmpc <- case ModulePathCondition
mpc of
        MPCCond GenExpr Identifier () Attributes
e ->
          Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' ()
"if" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
gpar
            (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent (GenExpr Identifier () Attributes)
-> GenExpr Identifier () Attributes
-> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent Identifier
-> (() -> Reader PrintingOpts (Doc' ()))
-> (Attributes -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr Identifier () Attributes)
forall i r a.
PrettyIdent i
-> (r -> Reader PrintingOpts (Doc' ()))
-> (a -> Reader PrintingOpts (Doc' ()))
-> Int
-> PrettyIdent (GenExpr i r a)
prettyGExpr PrettyIdent Identifier
prettyIdent (Reader PrintingOpts (Doc' ())
-> () -> Reader PrintingOpts (Doc' ())
forall a b. a -> b -> a
const (Reader PrintingOpts (Doc' ())
 -> () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
-> ()
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) Attributes -> Reader PrintingOpts (Doc' ())
prettyAttr Int
12) GenExpr Identifier () Attributes
e
        ModulePathCondition
MPCAlways -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty
        ModulePathCondition
MPCNone -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
"ifnone"
      Doc' ()
dpd <- SpecPath
-> Maybe Bool
-> Maybe (Expr, Maybe Bool)
-> Reader PrintingOpts (Doc' ())
prettyPathDecl SpecPath
p Maybe Bool
pol Maybe (Expr, Maybe Bool)
eds
      Doc' ()
d <- PrettyIdent PathDelayValue
-> PathDelayValue -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' () -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
prettyEq Doc' ()
dpd) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> PrettyIdent PathDelayValue -> PrettyIdent PathDelayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent CMinTypMax -> PrettyIdent (NonEmpty CMinTypMax)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent CMinTypMax
prettyCMTM PrettyIdent (NonEmpty CMinTypMax)
-> (PathDelayValue -> NonEmpty CMinTypMax)
-> PrettyIdent PathDelayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathDelayValue -> NonEmpty CMinTypMax
cPDV) PathDelayValue
l
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
dmpc Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
    SISetup (STCArgs TimingCheckEvent
d TimingCheckEvent
r Expr
e Maybe Identifier
n) -> (\Doc' ()
x -> Doc' ()
"$setup" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> Reader PrintingOpts (Doc' ())
ppA (TimingCheckEvent
-> TimingCheckEvent -> Expr -> Maybe Identifier -> STCArgs
STCArgs TimingCheckEvent
r TimingCheckEvent
d Expr
e Maybe Identifier
n)
    SIHold STCArgs
a -> (\Doc' ()
x -> Doc' ()
"$hold" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> Reader PrintingOpts (Doc' ())
ppA STCArgs
a
    SISetupHold STCArgs
a STCAddArgs
aa -> (\Doc' ()
x -> Doc' ()
"$setuphold" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> STCAddArgs -> Reader PrintingOpts (Doc' ())
ppAA STCArgs
a STCAddArgs
aa
    SIRecovery STCArgs
a -> (\Doc' ()
x -> Doc' ()
"$recovery" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> Reader PrintingOpts (Doc' ())
ppA STCArgs
a
    SIRemoval STCArgs
a -> (\Doc' ()
x -> Doc' ()
"$removal" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> Reader PrintingOpts (Doc' ())
ppA STCArgs
a
    SIRecrem STCArgs
a STCAddArgs
aa -> (\Doc' ()
x -> Doc' ()
"$recrem" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> STCAddArgs -> Reader PrintingOpts (Doc' ())
ppAA STCArgs
a STCAddArgs
aa
    SISkew STCArgs
a -> (\Doc' ()
x -> Doc' ()
"$skew" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> STCArgs -> Reader PrintingOpts (Doc' ())
ppA STCArgs
a
    SITimeSkew (STCArgs TimingCheckEvent
de TimingCheckEvent
re Expr
tcl Maybe Identifier
n) Maybe CExpr
meb Maybe CExpr
mra -> do
      Doc' ()
dre <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
re
      Doc' ()
dde <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
de
      Doc' ()
dtcl <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
pid Maybe Identifier
n
      Doc' ()
dmeb <- (CExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr) Maybe CExpr
meb
      Doc' ()
dmra <- (CExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr) Maybe CExpr
mra
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"$timeskew" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' () -> Doc' ()
gpar (Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dde Doc' () -> Doc' () -> Doc' ()
<.> [Doc' ()] -> Doc' ()
toc [Item [Doc' ()]
Doc' ()
dtcl, Item [Doc' ()]
Doc' ()
dn, Item [Doc' ()]
Doc' ()
dmeb, Item [Doc' ()]
Doc' ()
dmra]) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
    SIFullSkew (STCArgs TimingCheckEvent
de TimingCheckEvent
re Expr
tcl0 Maybe Identifier
n) Expr
tcl1 Maybe CExpr
meb Maybe CExpr
mra -> do
      Doc' ()
dre <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
re
      Doc' ()
dde <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
de
      Doc' ()
dtcl0 <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl0
      Doc' ()
dtcl1 <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl1
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
pid Maybe Identifier
n
      Doc' ()
dmeb <- (CExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr) Maybe CExpr
meb
      Doc' ()
dmra <- (CExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr) Maybe CExpr
mra
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"$fullskew" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' () -> Doc' ()
gpar (Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dde Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dtcl0 Doc' () -> Doc' () -> Doc' ()
<.> [Doc' ()] -> Doc' ()
toc [Item [Doc' ()]
Doc' ()
dtcl1, Item [Doc' ()]
Doc' ()
dn, Item [Doc' ()]
Doc' ()
dmeb, Item [Doc' ()]
Doc' ()
dmra]) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
    SIPeriod ControlledTimingCheckEvent
re Expr
tcl Maybe Identifier
n -> do
      Doc' ()
dre <- ControlledTimingCheckEvent -> Reader PrintingOpts (Doc' ())
pCTCE ControlledTimingCheckEvent
re
      Doc' ()
dtcl <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
prid Maybe Identifier
n
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"$period" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' () -> Doc' ()
par (Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dtcl Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
dn) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
    SIWidth ControlledTimingCheckEvent
re Expr
tcl Maybe CExpr
mt Maybe Identifier
n -> do
      Doc' ()
dre <- ControlledTimingCheckEvent -> Reader PrintingOpts (Doc' ())
pCTCE ControlledTimingCheckEvent
re
      Doc' ()
dtcl <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl
      Doc' ()
dmt <- (CExpr -> Reader PrintingOpts (Doc' ()))
-> Maybe CExpr -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr) Maybe CExpr
mt
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
pid Maybe Identifier
n
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"$width" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' () -> Doc' ()
gpar (Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> [Doc' ()] -> Doc' ()
toc [Item [Doc' ()]
Doc' ()
dtcl, Item [Doc' ()]
Doc' ()
dmt, Item [Doc' ()]
Doc' ()
dn]) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
    SINoChange TimingCheckEvent
re TimingCheckEvent
de MinTypMax
so MinTypMax
eo Maybe Identifier
n -> do
      Doc' ()
dre <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
re
      Doc' ()
dde <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
de
      Doc' ()
dso <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
so
      Doc' ()
deo <- PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM MinTypMax
eo
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
prid Maybe Identifier
n
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
"$nochange" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
</> Doc' () -> Doc' ()
gpar (Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dde Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dso Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
deo Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
dn) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
  where
    toc :: [Doc] -> Doc
    toc :: [Doc' ()] -> Doc' ()
toc = (Doc' () -> Doc' () -> Doc' ()) -> [Doc' ()] -> Doc' ()
forall (f :: * -> *) w.
Foldable f =>
(Doc' w -> Doc' w -> Doc' w) -> f (Doc' w) -> Doc' w
trailoptcat Doc' () -> Doc' () -> Doc' ()
(<.>)
    prid :: Maybe Identifier -> Reader PrintingOpts (Doc' ())
prid = (Identifier -> Reader PrintingOpts (Doc' ()))
-> Maybe Identifier -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Identifier -> Reader PrintingOpts (Doc' ()))
 -> Maybe Identifier -> Reader PrintingOpts (Doc' ()))
-> (Identifier -> Reader PrintingOpts (Doc' ()))
-> Maybe Identifier
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' ()
forall w. Doc' w
comma Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+>) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Identifier -> Reader PrintingOpts (Doc' ()))
-> Identifier
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent
    pid :: Maybe Identifier -> Reader PrintingOpts (Doc' ())
pid = (Identifier -> Reader PrintingOpts (Doc' ()))
-> Maybe Identifier -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Identifier -> Reader PrintingOpts (Doc' ()))
 -> Maybe Identifier -> Reader PrintingOpts (Doc' ()))
-> (Identifier -> Reader PrintingOpts (Doc' ()))
-> Maybe Identifier
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent
    pexpr :: Expr -> Reader PrintingOpts (Doc' ())
pexpr = PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent Expr
prettyExpr
    pTCC :: SpecTerm -> Maybe (Bool, Expr) -> Reader PrintingOpts (Doc' ())
pTCC SpecTerm
st Maybe (Bool, Expr)
mbe = case Maybe (Bool, Expr)
mbe of
      Maybe (Bool, Expr)
Nothing -> PrettyIdent SpecTerm -> SpecTerm -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent SpecTerm
prettySpecTerm SpecTerm
st
      Just (Bool
b, Expr
e) -> do
        (Doc' (), Doc' ())
dst <- PrettyIdent SpecTerm
prettySpecTerm SpecTerm
st
        Doc' ()
de <- PrettyIdent Expr -> Expr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent Expr
prettyExpr Expr
e
        Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group ((Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), Doc' ())
dst) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
"&&&" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' () -> Bool -> Doc' ()
pift Doc' ()
"~" Bool
b Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?+> Doc' ()
de
    pTCE :: TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE (TimingCheckEvent Maybe EdgeDesc
ev SpecTerm
st Maybe (Bool, Expr)
tc) = Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<?=>) ((EdgeDesc -> Reader PrintingOpts (Doc' ()))
-> Maybe EdgeDesc -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm EdgeDesc -> Reader PrintingOpts (Doc' ())
prettyEdgeDesc Maybe EdgeDesc
ev) (SpecTerm -> Maybe (Bool, Expr) -> Reader PrintingOpts (Doc' ())
pTCC SpecTerm
st Maybe (Bool, Expr)
tc)
    pCTCE :: ControlledTimingCheckEvent -> Reader PrintingOpts (Doc' ())
pCTCE (ControlledTimingCheckEvent EdgeDesc
ev SpecTerm
st Maybe (Bool, Expr)
tc) =
      Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<?=>) (EdgeDesc -> Reader PrintingOpts (Doc' ())
prettyEdgeDesc EdgeDesc
ev) (SpecTerm -> Maybe (Bool, Expr) -> Reader PrintingOpts (Doc' ())
pTCC SpecTerm
st Maybe (Bool, Expr)
tc)
    ppA :: STCArgs -> Reader PrintingOpts (Doc' ())
ppA (STCArgs TimingCheckEvent
de TimingCheckEvent
re Expr
tcl Maybe Identifier
n) = do
      Doc' ()
dre <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
re
      Doc' ()
dde <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
de
      Doc' ()
dtcl <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
prid Maybe Identifier
n
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dde Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dtcl Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
dn
    pIMTM :: Maybe (Identified (Maybe CMinTypMax))
-> Reader PrintingOpts (Doc' ())
pIMTM = (Identified (Maybe CMinTypMax) -> Reader PrintingOpts (Doc' ()))
-> Maybe (Identified (Maybe CMinTypMax))
-> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Identified (Maybe CMinTypMax) -> Reader PrintingOpts (Doc' ()))
 -> Maybe (Identified (Maybe CMinTypMax))
 -> Reader PrintingOpts (Doc' ()))
-> (Identified (Maybe CMinTypMax) -> Reader PrintingOpts (Doc' ()))
-> Maybe (Identified (Maybe CMinTypMax))
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ \(Identified Identifier
i Maybe CMinTypMax
mr) ->
      (CMinTypMax -> Reader PrintingOpts (Doc' ()))
-> Maybe CMinTypMax -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm ((Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc' () -> Doc' ()
brk) (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (CMinTypMax -> Reader PrintingOpts (Doc' ()))
-> CMinTypMax
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent CMinTypMax
-> CMinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent CMinTypMax
prettyCMTM) Maybe CMinTypMax
mr Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Doc' ()
d -> PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj (PrettyIdent Identifier -> Doc' () -> PrettyIdent Identifier
forall a. PrettyIdent a -> Doc' () -> PrettyIdent a
padjWith PrettyIdent Identifier
prettyIdent Doc' ()
d) Identifier
i
    ppAA :: STCArgs -> STCAddArgs -> Reader PrintingOpts (Doc' ())
ppAA (STCArgs TimingCheckEvent
de TimingCheckEvent
re Expr
tcl0 Maybe Identifier
n) (STCAddArgs Expr
tcl1 Maybe MinTypMax
msc Maybe MinTypMax
mtc Maybe (Identified (Maybe CMinTypMax))
mdr Maybe (Identified (Maybe CMinTypMax))
mdd) = do
      Doc' ()
dre <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
re
      Doc' ()
dde <- TimingCheckEvent -> Reader PrintingOpts (Doc' ())
pTCE TimingCheckEvent
de
      Doc' ()
dtcl0 <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl0
      Doc' ()
dtcl1 <- Expr -> Reader PrintingOpts (Doc' ())
pexpr Expr
tcl1
      Doc' ()
dn <- Maybe Identifier -> Reader PrintingOpts (Doc' ())
pid Maybe Identifier
n
      Doc' ()
dmsc <- (MinTypMax -> Reader PrintingOpts (Doc' ()))
-> Maybe MinTypMax -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM) Maybe MinTypMax
msc
      Doc' ()
dmtc <- (MinTypMax -> Reader PrintingOpts (Doc' ()))
-> Maybe MinTypMax -> Reader PrintingOpts (Doc' ())
forall x.
(x -> Reader PrintingOpts (Doc' ()))
-> Maybe x -> Reader PrintingOpts (Doc' ())
pm (PrettyIdent MinTypMax -> MinTypMax -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
ngpadj PrettyIdent MinTypMax
prettyMTM) Maybe MinTypMax
mtc
      Doc' ()
dmdr <- Maybe (Identified (Maybe CMinTypMax))
-> Reader PrintingOpts (Doc' ())
pIMTM Maybe (Identified (Maybe CMinTypMax))
mdr
      Doc' ()
dmdd <- Maybe (Identified (Maybe CMinTypMax))
-> Reader PrintingOpts (Doc' ())
pIMTM Maybe (Identified (Maybe CMinTypMax))
mdd
      Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
gpar (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
dre Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dde Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
dtcl0 Doc' () -> Doc' () -> Doc' ()
<.> [Doc' ()] -> Doc' ()
toc [Item [Doc' ()]
Doc' ()
dtcl1, Item [Doc' ()]
Doc' ()
dn, Item [Doc' ()]
Doc' ()
dmsc, Item [Doc' ()]
Doc' ()
dmtc, Item [Doc' ()]
Doc' ()
dmdr, Item [Doc' ()]
Doc' ()
dmdd]
    cPDV :: PathDelayValue -> NonEmpty CMinTypMax
cPDV PathDelayValue
x = case PathDelayValue
x of
      PDV1 CMinTypMax
e -> CMinTypMax
e CMinTypMax -> [CMinTypMax] -> NonEmpty CMinTypMax
forall a. a -> [a] -> NonEmpty a
:|[]
      PDV2 CMinTypMax
e1 CMinTypMax
e2 -> [Item (NonEmpty CMinTypMax)
CMinTypMax
e1, Item (NonEmpty CMinTypMax)
CMinTypMax
e2]
      PDV3 CMinTypMax
e1 CMinTypMax
e2 CMinTypMax
e3 -> [Item (NonEmpty CMinTypMax)
CMinTypMax
e1, Item (NonEmpty CMinTypMax)
CMinTypMax
e2, Item (NonEmpty CMinTypMax)
CMinTypMax
e3]
      PDV6 CMinTypMax
e1 CMinTypMax
e2 CMinTypMax
e3 CMinTypMax
e4 CMinTypMax
e5 CMinTypMax
e6 -> [Item (NonEmpty CMinTypMax)
CMinTypMax
e1, Item (NonEmpty CMinTypMax)
CMinTypMax
e2, Item (NonEmpty CMinTypMax)
CMinTypMax
e3, Item (NonEmpty CMinTypMax)
CMinTypMax
e4, Item (NonEmpty CMinTypMax)
CMinTypMax
e5, Item (NonEmpty CMinTypMax)
CMinTypMax
e6]
      PDV12 CMinTypMax
e1 CMinTypMax
e2 CMinTypMax
e3 CMinTypMax
e4 CMinTypMax
e5 CMinTypMax
e6 CMinTypMax
e7 CMinTypMax
e8 CMinTypMax
e9 CMinTypMax
e10 CMinTypMax
e11 CMinTypMax
e12 ->
        [Item (NonEmpty CMinTypMax)
CMinTypMax
e1, Item (NonEmpty CMinTypMax)
CMinTypMax
e2, Item (NonEmpty CMinTypMax)
CMinTypMax
e3, Item (NonEmpty CMinTypMax)
CMinTypMax
e4, Item (NonEmpty CMinTypMax)
CMinTypMax
e5, Item (NonEmpty CMinTypMax)
CMinTypMax
e6, Item (NonEmpty CMinTypMax)
CMinTypMax
e7, Item (NonEmpty CMinTypMax)
CMinTypMax
e8, Item (NonEmpty CMinTypMax)
CMinTypMax
e9, Item (NonEmpty CMinTypMax)
CMinTypMax
e10, Item (NonEmpty CMinTypMax)
CMinTypMax
e11, Item (NonEmpty CMinTypMax)
CMinTypMax
e12]

data ModuleItem'
  = MI'MGI (Attributed ModGenSingleItem)
  | MI'Port Attributes Dir SignRange (NonEmpty Identifier)
  | MI'Parameter Attributes (ComType ()) (NonEmpty (Identified CMinTypMax))
  | MI'GenReg [Attributed ModGenSingleItem]
  | MI'SpecParam Attributes (Maybe Range2) (NonEmpty SpecParamDecl)
  | MI'SpecBlock [SpecifySingleItem]

prettyModuleItems :: [ModuleItem] -> Print
prettyModuleItems :: [ModuleItem] -> Reader PrintingOpts (Doc' ())
prettyModuleItems =
  Reader PrintingOpts (Doc' ())
-> (NonEmpty ModuleItem -> Reader PrintingOpts (Doc' ()))
-> [ModuleItem]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (NonEmpty a -> b) -> [a] -> b
nonEmpty (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) ((NonEmpty ModuleItem -> Reader PrintingOpts (Doc' ()))
 -> [ModuleItem] -> Reader PrintingOpts (Doc' ()))
-> (NonEmpty ModuleItem -> Reader PrintingOpts (Doc' ()))
-> [ModuleItem]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
    (Doc' () -> Doc' () -> Doc' ())
-> (ModuleItem' -> Reader PrintingOpts (Doc' ()))
-> (ModuleItem -> ModuleItem')
-> (ModuleItem -> ModuleItem' -> Maybe ModuleItem')
-> NonEmpty ModuleItem
-> Reader PrintingOpts (Doc' ())
forall y x.
(Doc' () -> Doc' () -> Doc' ())
-> (y -> Reader PrintingOpts (Doc' ()))
-> (x -> y)
-> (x -> y -> Maybe y)
-> NonEmpty x
-> Reader PrintingOpts (Doc' ())
prettyregroup
      Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>)
      ( \ModuleItem'
x -> case ModuleItem'
x of
        MI'MGI (Attributed Attributes
a ModGenSingleItem
i) -> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ModGenSingleItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenSingleItem ModGenSingleItem
i Bool
False
        MI'Port Attributes
a Dir
d SignRange
sr NonEmpty Identifier
l -> do
          Doc' ()
dsr <- SignRange -> Reader PrintingOpts (Doc' ())
prettySignRange SignRange
sr
          Doc' ()
it <- Doc' ()
-> PrettyIdent Identifier
-> NonEmpty Identifier
-> Reader PrintingOpts (Doc' ())
forall a.
Doc' ()
-> PrettyIdent a -> NonEmpty a -> Reader PrintingOpts (Doc' ())
prettyItemsid (Dir -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Dir
d Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dsr) PrettyIdent Identifier
prettyIdent NonEmpty Identifier
l
          Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a Doc' ()
it
        MI'Parameter Attributes
a ComType ()
t NonEmpty (Identified CMinTypMax)
l -> ByteString
-> ComType ()
-> NonEmpty (Identified CMinTypMax)
-> Reader PrintingOpts (Doc' ())
prettyXparam ByteString
"parameter" ComType ()
t NonEmpty (Identified CMinTypMax)
l Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a
        MI'GenReg [Attributed ModGenSingleItem]
l ->
          Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block Doc' ()
"generate" Doc' ()
"endgenerate" (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
            (Doc' () -> Doc' () -> Doc' ())
-> (Attributed ModGenSingleItem -> Reader PrintingOpts (Doc' ()))
-> [Attributed ModGenSingleItem]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) (\(Attributed Attributes
a ModGenSingleItem
i) -> Attributes
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
prettyAttrThen Attributes
a (Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ModGenSingleItem -> Bool -> Reader PrintingOpts (Doc' ())
prettyModGenSingleItem ModGenSingleItem
i Bool
False) [Attributed ModGenSingleItem]
l
        MI'SpecParam Attributes
a Maybe Range2
r NonEmpty SpecParamDecl
l -> Maybe Range2
-> NonEmpty SpecParamDecl -> Reader PrintingOpts (Doc' ())
prettySpecParams Maybe Range2
r NonEmpty SpecParamDecl
l Reader PrintingOpts (Doc' ())
-> (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Reader PrintingOpts (Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyAttrng Attributes
a
        MI'SpecBlock [SpecifySingleItem]
l -> Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block Doc' ()
"specify" Doc' ()
"endspecify" (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> (SpecifySingleItem -> Reader PrintingOpts (Doc' ()))
-> [SpecifySingleItem]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) SpecifySingleItem -> Reader PrintingOpts (Doc' ())
prettySpecifyItem [SpecifySingleItem]
l
      )
      ( \ModuleItem
x -> case ModuleItem
x of
        MIMGI Attributed ModGenBlockedItem
i -> Attributed ModGenSingleItem -> ModuleItem'
MI'MGI (Attributed ModGenSingleItem -> ModuleItem')
-> Attributed ModGenSingleItem -> ModuleItem'
forall a b. (a -> b) -> a -> b
$ ModGenBlockedItem -> ModGenSingleItem
fromMGBlockedItem1 (ModGenBlockedItem -> ModGenSingleItem)
-> Attributed ModGenBlockedItem -> Attributed ModGenSingleItem
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Attributed ModGenBlockedItem
i
        MIPort (AttrIded Attributes
a Identifier
i (Dir
d, SignRange
sr)) -> Attributes
-> Dir -> SignRange -> NonEmpty Identifier -> ModuleItem'
MI'Port Attributes
a Dir
d SignRange
sr [Item (NonEmpty Identifier)
Identifier
i]
        MIParameter (AttrIded Attributes
a Identifier
i (Parameter ComType ()
t CMinTypMax
v)) -> Attributes
-> ComType () -> NonEmpty (Identified CMinTypMax) -> ModuleItem'
MI'Parameter Attributes
a ComType ()
t [Identifier -> CMinTypMax -> Identified CMinTypMax
forall t. Identifier -> t -> Identified t
Identified Identifier
i CMinTypMax
v]
        MIGenReg [Attributed ModGenBlockedItem]
l -> [Attributed ModGenSingleItem] -> ModuleItem'
MI'GenReg ([Attributed ModGenSingleItem] -> ModuleItem')
-> [Attributed ModGenSingleItem] -> ModuleItem'
forall a b. (a -> b) -> a -> b
$ [Attributed ModGenBlockedItem] -> [Attributed ModGenSingleItem]
fromMGBlockedItem [Attributed ModGenBlockedItem]
l
        MISpecParam Attributes
a Maybe Range2
r SpecParamDecl
spd -> Attributes -> Maybe Range2 -> NonEmpty SpecParamDecl -> ModuleItem'
MI'SpecParam Attributes
a Maybe Range2
r [Item (NonEmpty SpecParamDecl)
SpecParamDecl
spd]
        MISpecBlock [SpecifyBlockedItem]
l -> [SpecifySingleItem] -> ModuleItem'
MI'SpecBlock ([SpecifySingleItem] -> ModuleItem')
-> [SpecifySingleItem] -> ModuleItem'
forall a b. (a -> b) -> a -> b
$ [SpecifyBlockedItem] -> [SpecifySingleItem]
fromSpecBlockedItem [SpecifyBlockedItem]
l
      )
      ( \ModuleItem
mi ModuleItem'
mi' -> case (ModuleItem
mi, ModuleItem'
mi') of
        (MIMGI Attributed ModGenBlockedItem
mgi, MI'MGI Attributed ModGenSingleItem
l) -> Attributed ModGenSingleItem -> ModuleItem'
MI'MGI (Attributed ModGenSingleItem -> ModuleItem')
-> Maybe (Attributed ModGenSingleItem) -> Maybe ModuleItem'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((ModGenBlockedItem -> ModGenSingleItem -> Maybe ModGenSingleItem)
-> Attributed ModGenBlockedItem
-> Attributed ModGenSingleItem
-> Maybe (Attributed ModGenSingleItem)
forall x y.
(x -> y -> Maybe y)
-> Attributed x -> Attributed y -> Maybe (Attributed y)
addAttributed ModGenBlockedItem -> ModGenSingleItem -> Maybe ModGenSingleItem
fromMGBlockedItem_add) Attributed ModGenBlockedItem
mgi Attributed ModGenSingleItem
l
        (MIPort (AttrIded Attributes
na Identifier
i (Dir
nd, SignRange
nsr)), MI'Port Attributes
a Dir
d SignRange
sr NonEmpty Identifier
l) | Attributes
na Attributes -> Attributes -> Bool
forall a. Eq a => a -> a -> Bool
== Attributes
a Bool -> Bool -> Bool
&& Dir
nd Dir -> Dir -> Bool
forall a. Eq a => a -> a -> Bool
== Dir
d Bool -> Bool -> Bool
&& SignRange
nsr SignRange -> SignRange -> Bool
forall a. Eq a => a -> a -> Bool
== SignRange
sr ->
          ModuleItem' -> Maybe ModuleItem'
forall a. a -> Maybe a
Just (ModuleItem' -> Maybe ModuleItem')
-> ModuleItem' -> Maybe ModuleItem'
forall a b. (a -> b) -> a -> b
$ Attributes
-> Dir -> SignRange -> NonEmpty Identifier -> ModuleItem'
MI'Port Attributes
a Dir
d SignRange
sr (NonEmpty Identifier -> ModuleItem')
-> NonEmpty Identifier -> ModuleItem'
forall a b. (a -> b) -> a -> b
$ Identifier
i Identifier -> NonEmpty Identifier -> NonEmpty Identifier
forall a. a -> NonEmpty a -> NonEmpty a
<| NonEmpty Identifier
l
        (MIParameter (AttrIded Attributes
na Identifier
i (Parameter ComType ()
nt CMinTypMax
v)), MI'Parameter Attributes
a ComType ()
t NonEmpty (Identified CMinTypMax)
l) | Attributes
na Attributes -> Attributes -> Bool
forall a. Eq a => a -> a -> Bool
== Attributes
a Bool -> Bool -> Bool
&& ComType ()
nt ComType () -> ComType () -> Bool
forall a. Eq a => a -> a -> Bool
== ComType ()
t ->
          ModuleItem' -> Maybe ModuleItem'
forall a. a -> Maybe a
Just (ModuleItem' -> Maybe ModuleItem')
-> ModuleItem' -> Maybe ModuleItem'
forall a b. (a -> b) -> a -> b
$ Attributes
-> ComType () -> NonEmpty (Identified CMinTypMax) -> ModuleItem'
MI'Parameter Attributes
a ComType ()
t (NonEmpty (Identified CMinTypMax) -> ModuleItem')
-> NonEmpty (Identified CMinTypMax) -> ModuleItem'
forall a b. (a -> b) -> a -> b
$ Identifier -> CMinTypMax -> Identified CMinTypMax
forall t. Identifier -> t -> Identified t
Identified Identifier
i CMinTypMax
v Identified CMinTypMax
-> NonEmpty (Identified CMinTypMax)
-> NonEmpty (Identified CMinTypMax)
forall a. a -> NonEmpty a -> NonEmpty a
<| NonEmpty (Identified CMinTypMax)
l
        (MISpecParam Attributes
na Maybe Range2
nr SpecParamDecl
spd, MI'SpecParam Attributes
a Maybe Range2
r NonEmpty SpecParamDecl
l) | Attributes
na Attributes -> Attributes -> Bool
forall a. Eq a => a -> a -> Bool
== Attributes
a Bool -> Bool -> Bool
&& Maybe Range2
nr Maybe Range2 -> Maybe Range2 -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe Range2
r ->
          ModuleItem' -> Maybe ModuleItem'
forall a. a -> Maybe a
Just (ModuleItem' -> Maybe ModuleItem')
-> ModuleItem' -> Maybe ModuleItem'
forall a b. (a -> b) -> a -> b
$ Attributes -> Maybe Range2 -> NonEmpty SpecParamDecl -> ModuleItem'
MI'SpecParam Attributes
a Maybe Range2
r (NonEmpty SpecParamDecl -> ModuleItem')
-> NonEmpty SpecParamDecl -> ModuleItem'
forall a b. (a -> b) -> a -> b
$ SpecParamDecl
spd SpecParamDecl -> NonEmpty SpecParamDecl -> NonEmpty SpecParamDecl
forall a. a -> NonEmpty a -> NonEmpty a
<| NonEmpty SpecParamDecl
l
        (ModuleItem, ModuleItem')
_ -> Maybe ModuleItem'
forall a. Maybe a
Nothing
      )

prettyPortInter :: [Identified [Identified (Maybe CRangeExpr)]] -> Print
prettyPortInter :: [Identified [Identified (Maybe CRangeExpr)]]
-> Reader PrintingOpts (Doc' ())
prettyPortInter =
  Doc' ()
-> Doc' ()
-> PrettyIdent (Identified [Identified (Maybe CRangeExpr)])
-> [Identified [Identified (Maybe CRangeExpr)]]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
cslid Doc' ()
forall a. Monoid a => a
mempty Doc' ()
forall a. Monoid a => a
mempty (PrettyIdent (Identified [Identified (Maybe CRangeExpr)])
 -> [Identified [Identified (Maybe CRangeExpr)]]
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent (Identified [Identified (Maybe CRangeExpr)])
-> [Identified [Identified (Maybe CRangeExpr)]]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
    \(Identified i :: Identifier
i@(Identifier ByteString
ii) [Identified (Maybe CRangeExpr)]
l) -> case [Identified (Maybe CRangeExpr)]
l of
      [Identified Identifier
i' Maybe CRangeExpr
x] | Identifier
i Identifier -> Identifier -> Bool
forall a. Eq a => a -> a -> Bool
== Identifier
i' -> (Doc' () -> Doc' ()) -> (Doc' (), Doc' ()) -> (Doc' (), Doc' ())
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group ((Doc' (), Doc' ()) -> (Doc' (), Doc' ()))
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent SpecTerm
prettySpecTerm (Identifier -> Maybe CRangeExpr -> SpecTerm
SpecTerm Identifier
i Maybe CRangeExpr
x)
      [Identified (Maybe CRangeExpr)]
_ ->
        if ByteString -> Bool
B.null ByteString
ii
          then PrettyIdent [Identified (Maybe CRangeExpr)]
portexpr [Identified (Maybe CRangeExpr)]
l
          else do
            Doc' ()
di <- PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent Identifier
i
            Doc' ()
de <- PrettyIdent [Identified (Maybe CRangeExpr)]
-> [Identified (Maybe CRangeExpr)] -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent [Identified (Maybe CRangeExpr)]
portexpr [Identified (Maybe CRangeExpr)]
l
            PrettyIdent (Doc' ())
mkid PrettyIdent (Doc' ()) -> PrettyIdent (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
forall w. Doc' w
dot Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
di Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar Doc' ()
de
  where
    pst :: Identified (Maybe CRangeExpr)
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
pst (Identified Identifier
i Maybe CRangeExpr
x) = PrettyIdent SpecTerm
prettySpecTerm PrettyIdent SpecTerm -> PrettyIdent SpecTerm
forall a b. (a -> b) -> a -> b
$ Identifier -> Maybe CRangeExpr -> SpecTerm
SpecTerm Identifier
i Maybe CRangeExpr
x
    portexpr :: PrettyIdent [Identified (Maybe CRangeExpr)]
    portexpr :: PrettyIdent [Identified (Maybe CRangeExpr)]
portexpr [Identified (Maybe CRangeExpr)]
l = case [Identified (Maybe CRangeExpr)]
l of
      [] -> (Doc' (), Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' ()
forall a. Monoid a => a
mempty, Doc' ()
forall a. Monoid a => a
mempty)
      [Item [Identified (Maybe CRangeExpr)]
x] -> Identified (Maybe CRangeExpr)
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
pst Item [Identified (Maybe CRangeExpr)]
Identified (Maybe CRangeExpr)
x
      [Identified (Maybe CRangeExpr)]
_ -> Doc' ()
-> Doc' ()
-> (Identified (Maybe CRangeExpr)
    -> ReaderT PrintingOpts Identity (Doc' (), Doc' ()))
-> [Identified (Maybe CRangeExpr)]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
Doc' ()
-> Doc' () -> PrettyIdent a -> f a -> Reader PrintingOpts (Doc' ())
cslid (Doc' ()
forall w. Doc' w
lbrace Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
softspace) Doc' ()
forall w. Doc' w
rbrace Identified (Maybe CRangeExpr)
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
pst [Identified (Maybe CRangeExpr)]
l Reader PrintingOpts (Doc' ())
-> PrettyIdent (Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
forall a b.
ReaderT PrintingOpts Identity a
-> (a -> ReaderT PrintingOpts Identity b)
-> ReaderT PrintingOpts Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PrettyIdent (Doc' ())
mkid

prettyModuleBlock :: LocalCompDir -> ModuleBlock -> Reader PrintingOpts (Doc, LocalCompDir)
prettyModuleBlock :: LocalCompDir
-> ModuleBlock -> Reader PrintingOpts (Doc' (), LocalCompDir)
prettyModuleBlock (LocalCompDir Maybe (Int, Int)
ts Bool
c Maybe Bool
p Maybe NetType
dn) (ModuleBlock Attributes
a Identifier
i [Identified [Identified (Maybe CRangeExpr)]]
pi [ModuleItem]
b Maybe (Int, Int)
mts Bool
mc Maybe Bool
mp Maybe NetType
mdn) = do
  Doc' ()
head <- (Doc' () -> Doc' ())
-> PrettyIdent Identifier
-> Identifier
-> Reader PrintingOpts (Doc' ())
forall a.
(Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
fpadj (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' ()
"module" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>)) PrettyIdent Identifier
prettyIdent Identifier
i
  Doc' ()
ports <- [Identified [Identified (Maybe CRangeExpr)]]
-> Reader PrintingOpts (Doc' ())
prettyPortInter [Identified [Identified (Maybe CRangeExpr)]]
pi
  Doc' ()
header <- Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyItem Attributes
a (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar Doc' ()
ports
  Doc' ()
body <- [ModuleItem] -> Reader PrintingOpts (Doc' ())
prettyModuleItems [ModuleItem]
b
  let
    dts :: Doc' ()
dts =
      Doc' () -> Bool -> Doc' ()
piff (let (Int
a, Int
b) = Maybe (Int, Int) -> (Int, Int)
forall a. HasCallStack => Maybe a -> a
fromJust Maybe (Int, Int)
mts in Doc' ()
"`timescale" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Int -> Doc' ()
forall {a} {a}. (Semigroup a, IsString a, Integral a) => a -> a
tsval Int
a Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
"/" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Int -> Doc' ()
forall {a} {a}. (Semigroup a, IsString a, Integral a) => a -> a
tsval Int
b) (Maybe (Int, Int)
ts Maybe (Int, Int) -> Maybe (Int, Int) -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe (Int, Int)
mts)
    dcd :: Doc' ()
dcd = Doc' () -> Bool -> Doc' ()
piff (if Bool
mc then Doc' ()
"`celldefine" else Doc' ()
"`endcelldefine") (Bool
c Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
mc)
    dud :: Doc' ()
dud =
      Doc' () -> Bool -> Doc' ()
piff
        ( case Maybe Bool
mp of
            Maybe Bool
Nothing -> Doc' ()
"`nounconnected_drive"
            Just Bool
b -> Doc' ()
"`unconnected_drive pull" Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> if Bool
b then Doc' ()
"1" else Doc' ()
"0"
        )
        (Maybe Bool
p Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe Bool
mp)
    ddn :: Doc' ()
ddn = Doc' () -> Bool -> Doc' ()
piff (Doc' ()
"`default_nettype" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' () -> (NetType -> Doc' ()) -> Maybe NetType -> Doc' ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc' ()
"none" NetType -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Maybe NetType
mdn) (Maybe NetType
dn Maybe NetType -> Maybe NetType -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe NetType
mdn)
  (Doc' (), LocalCompDir)
-> Reader PrintingOpts (Doc' (), LocalCompDir)
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return
    (Doc' ()
dts Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' ()
dcd Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' ()
dud Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' ()
ddn Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block Doc' ()
header Doc' ()
"endmodule" Doc' ()
body, Maybe (Int, Int)
-> Bool -> Maybe Bool -> Maybe NetType -> LocalCompDir
LocalCompDir Maybe (Int, Int)
mts Bool
mc Maybe Bool
mp Maybe NetType
mdn)
  where
    tsval :: a -> a
tsval a
i =
      let (a
u, a
v) = a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
divMod a
i a
3
       in case a
v of a
0 -> a
"1"; a
1 -> a
"10"; a
2 -> a
"100"
            a -> a -> a
forall a. Semigroup a => a -> a -> a
<> case a
u of a
0 -> a
"s"; -1 -> a
"ms"; -2 -> a
"us"; -3 -> a
"ns"; -4 -> a
"ps"; -5 -> a
"fs"

prettyPrimPorts :: (Attributes, PrimPort, NonEmpty Identifier) -> Print
prettyPrimPorts :: (Attributes, PrimPort, NonEmpty Identifier)
-> Reader PrintingOpts (Doc' ())
prettyPrimPorts (Attributes
a, PrimPort
d, NonEmpty Identifier
l) = do
  (Doc' ()
ids, Doc' ()
s) <- PrettyIdent Identifier -> PrettyIdent (NonEmpty Identifier)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent Identifier
prettyIdent NonEmpty Identifier
l
  Doc' ()
ports <- case PrimPort
d of
    PPOutReg (Just CExpr
e) -> (\Doc' ()
x -> Doc' ()
ids Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
forall w. Doc' w
equals Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' ()
x) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent CExpr -> CExpr -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent CExpr
prettyCExpr CExpr
e
    PrimPort
_ -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
ids Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
s
  Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyItem Attributes
a (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
    (case PrimPort
d of PrimPort
PPInput -> Doc' ()
"input"; PrimPort
PPOutput -> Doc' ()
"output"; PrimPort
PPReg -> Doc' ()
"reg"; PPOutReg Maybe CExpr
_ -> Doc' ()
"output reg")
    Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
ports

-- | Analyses the column size of all lines and returns a list of either
-- | number of successive non-edge columns or the width of a column that contain edges
seqrowAlignment :: NonEmpty SeqRow -> [Either Int Int]
seqrowAlignment :: NonEmpty SeqRow -> [Either Int Int]
seqrowAlignment =
  [Either Int Int]
-> (([Either Int Int], Int) -> [Either Int Int])
-> Maybe ([Either Int Int], Int)
-> [Either Int Int]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ([Either Int Int], Int) -> [Either Int Int]
forall a b. (a, b) -> a
fst (Maybe ([Either Int Int], Int) -> [Either Int Int])
-> (NonEmpty SeqRow -> Maybe ([Either Int Int], Int))
-> NonEmpty SeqRow
-> [Either Int Int]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SeqRow -> Maybe ([Either Int Int], Int))
-> (SeqRow
    -> ([Either Int Int], Int) -> Maybe ([Either Int Int], Int))
-> NonEmpty SeqRow
-> Maybe ([Either Int Int], Int)
forall (m :: * -> *) a b.
(Applicative m, Monad m) =>
(a -> m b) -> (a -> b -> m b) -> NonEmpty a -> m b
foldrMapM1
    ( \sr :: SeqRow
sr@(SeqRow SeqIn
sri SigLevel
_ Maybe ZOX
_) -> ([Either Int Int], Int) -> Maybe ([Either Int Int], Int)
forall a. a -> Maybe a
Just (case SeqIn
sri of
        SISeq [SigLevel]
l0 Edge
e [SigLevel]
l1 -> [Int -> Either Int Int
forall a b. a -> Either a b
Left (Int -> Either Int Int) -> Int -> Either Int Int
forall a b. (a -> b) -> a -> b
$ [SigLevel] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SigLevel]
l0, Int -> Either Int Int
forall a b. b -> Either a b
Right (Int -> Either Int Int) -> Int -> Either Int Int
forall a b. (a -> b) -> a -> b
$ Edge -> Int
forall {a}. Num a => Edge -> a
edgeprintsize Edge
e, Int -> Either Int Int
forall a b. a -> Either a b
Left (Int -> Either Int Int) -> Int -> Either Int Int
forall a b. (a -> b) -> a -> b
$ [SigLevel] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SigLevel]
l1]
        SIComb NonEmpty SigLevel
l -> [Int -> Either Int Int
forall a b. a -> Either a b
Left (Int -> Either Int Int) -> Int -> Either Int Int
forall a b. (a -> b) -> a -> b
$ NonEmpty SigLevel -> Int
forall a. NonEmpty a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length NonEmpty SigLevel
l],
      SeqRow -> Int
totallength SeqRow
sr)
    )
    ( \sr :: SeqRow
sr@(SeqRow SeqIn
sri SigLevel
_ Maybe ZOX
_) ([Either Int Int]
sl, Int
tl) ->
        if SeqRow -> Int
totallength SeqRow
sr Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
tl
          then Maybe ([Either Int Int], Int)
forall a. Maybe a
Nothing
          else case SeqIn
sri of
            SISeq [SigLevel]
l0 Edge
e [SigLevel]
l1 -> (,) ([Either Int Int] -> Int -> ([Either Int Int], Int))
-> Maybe [Either Int Int] -> Maybe (Int -> ([Either Int Int], Int))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Int -> [Either Int Int] -> Maybe [Either Int Int]
forall {a} {b}.
(Num a, Ord a, Ord b) =>
b -> a -> [Either a b] -> Maybe [Either a b]
spliceputat (Edge -> Int
forall {a}. Num a => Edge -> a
edgeprintsize Edge
e) ([SigLevel] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SigLevel]
l0) [Either Int Int]
sl Maybe (Int -> ([Either Int Int], Int))
-> Maybe Int -> Maybe ([Either Int Int], Int)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> Maybe Int
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Int
tl
            SIComb NonEmpty SigLevel
l -> ([Either Int Int], Int) -> Maybe ([Either Int Int], Int)
forall a. a -> Maybe a
Just ([Either Int Int]
sl, Int
tl)
    )
  where
    totallength :: SeqRow -> Int
totallength SeqRow
sr =
      case SeqRow -> SeqIn
_srowInput SeqRow
sr of SIComb NonEmpty SigLevel
l -> NonEmpty SigLevel -> Int
forall a. NonEmpty a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length NonEmpty SigLevel
l; SISeq [SigLevel]
l0 Edge
e [SigLevel]
l1 -> Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [SigLevel] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SigLevel]
l0 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [SigLevel] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [SigLevel]
l1
    edgeprintsize :: Edge -> a
edgeprintsize Edge
x = case Edge
x of EdgePos_neg Bool
_ -> a
1; EdgeDesc SigLevel
_ SigLevel
_ -> a
4
    -- Searches and splices a streak of non edge columns and puts an edge column
    spliceputat :: b -> a -> [Either a b] -> Maybe [Either a b]
spliceputat b
w a
n [Either a b]
l = case [Either a b]
l of
      [] -> Maybe [Either a b]
forall a. Maybe a
Nothing
      Right b
w' : [Either a b]
t ->
        if a
0 a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
n
          then (b -> Either a b
forall a b. b -> Either a b
Right b
w' Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
:) ([Either a b] -> [Either a b])
-> Maybe [Either a b] -> Maybe [Either a b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> b -> a -> [Either a b] -> Maybe [Either a b]
spliceputat b
w (a
n a -> a -> a
forall a. Num a => a -> a -> a
- a
1) [Either a b]
t
          else [Either a b] -> Maybe [Either a b]
forall a. a -> Maybe a
Just ([Either a b] -> Maybe [Either a b])
-> [Either a b] -> Maybe [Either a b]
forall a b. (a -> b) -> a -> b
$ b -> Either a b
forall a b. b -> Either a b
Right (b -> b -> b
forall a. Ord a => a -> a -> a
max b
w b
w') Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
: [Either a b]
t
      Left a
m : [Either a b]
t -> case a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare a
m (a
n a -> a -> a
forall a. Num a => a -> a -> a
+ a
1) of
        Ordering
LT -> (a -> Either a b
forall a b. a -> Either a b
Left a
m Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
:) ([Either a b] -> [Either a b])
-> Maybe [Either a b] -> Maybe [Either a b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> b -> a -> [Either a b] -> Maybe [Either a b]
spliceputat b
w (a
n a -> a -> a
forall a. Num a => a -> a -> a
- a
m) [Either a b]
t
        Ordering
EQ -> [Either a b] -> Maybe [Either a b]
forall a. a -> Maybe a
Just ([Either a b] -> Maybe [Either a b])
-> [Either a b] -> Maybe [Either a b]
forall a b. (a -> b) -> a -> b
$ a -> Either a b
forall a b. a -> Either a b
Left a
n Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
: b -> Either a b
forall a b. b -> Either a b
Right b
w Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
: [Either a b]
t
        Ordering
GT -> [Either a b] -> Maybe [Either a b]
forall a. a -> Maybe a
Just ([Either a b] -> Maybe [Either a b])
-> [Either a b] -> Maybe [Either a b]
forall a b. (a -> b) -> a -> b
$ a -> Either a b
forall a b. a -> Either a b
Left a
n Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
: b -> Either a b
forall a b. b -> Either a b
Right b
w Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
: a -> Either a b
forall a b. a -> Either a b
Left (a
m a -> a -> a
forall a. Num a => a -> a -> a
- a
n a -> a -> a
forall a. Num a => a -> a -> a
- a
1) Either a b -> [Either a b] -> [Either a b]
forall a. a -> [a] -> [a]
: [Either a b]
t

-- | Prints levels or edges in an aligned way using analysis results
-- | the second part of the accumulation is Right if there is an edge, Left otherwise
prettySeqIn :: SeqIn -> [Either Int Int] -> Print
prettySeqIn :: SeqIn -> [Either Int Int] -> Reader PrintingOpts (Doc' ())
prettySeqIn SeqIn
si [Either Int Int]
l = do
  Bool
ts <- (PrintingOpts -> Bool) -> ReaderT PrintingOpts Identity Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PrintingOpts -> Bool
_poTableSpace
  let pcat :: (a -> Doc' w) -> [a] -> Doc' w
pcat a -> Doc' w
f = Doc' w -> (a -> Doc' w) -> (a -> Doc' w -> Doc' w) -> [a] -> Doc' w
forall b a. b -> (a -> b) -> (a -> b -> b) -> [a] -> b
foldrMap1' Doc' w
forall a. Monoid a => a
mempty a -> Doc' w
f ((if Bool
ts then Doc' w -> Doc' w -> Doc' w
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<+>) else Doc' w -> Doc' w -> Doc' w
forall a. Semigroup a => a -> a -> a
(<>)) (Doc' w -> Doc' w -> Doc' w)
-> (a -> Doc' w) -> a -> Doc' w -> Doc' w
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Doc' w
f)
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
    (Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
-> Doc' ()
forall a b. (a, b) -> a
fst ((Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
 -> Doc' ())
-> (Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
-> Doc' ()
forall a b. (a -> b) -> a -> b
$
      ((Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
 -> Either Int Int
 -> (Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel])))
-> (Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
-> [Either Int Int]
-> (Doc' (), Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl'
        ( \(Doc' ()
d, Either [SigLevel] ([SigLevel], Edge, [SigLevel])
si) Either Int Int
e -> case (Either Int Int
e, Either [SigLevel] ([SigLevel], Edge, [SigLevel])
si) of
            (Left Int
n, Left [SigLevel]
l') ->
              let ([SigLevel]
l0, [SigLevel]
l1) = Int -> [SigLevel] -> ([SigLevel], [SigLevel])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
n [SigLevel]
l'
               in (Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (SigLevel -> Doc' ()) -> [SigLevel] -> Doc' ()
forall {w} {a}.
(Ord w, Semigroup w, Enum w) =>
(a -> Doc' w) -> [a] -> Doc' w
pcat SigLevel -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow [SigLevel]
l0, [SigLevel] -> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. a -> Either a b
Left [SigLevel]
l1)
            (Right Int
w, Left (SigLevel
h : [SigLevel]
t)) -> (Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> SigLevel -> Int -> Doc' ()
forall {a} {a}. (Show a, Eq a, Num a) => a -> a -> Doc' ()
prettylevelwithwidth SigLevel
h Int
w, [SigLevel] -> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. a -> Either a b
Left [SigLevel]
t)
            (Left Int
n, Right ([SigLevel]
l0, Edge
e, [SigLevel]
l1)) ->
              let ([SigLevel]
l00, [SigLevel]
l01) = Int -> [SigLevel] -> ([SigLevel], [SigLevel])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
n [SigLevel]
l0
               in (Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> (SigLevel -> Doc' ()) -> [SigLevel] -> Doc' ()
forall {w} {a}.
(Ord w, Semigroup w, Enum w) =>
(a -> Doc' w) -> [a] -> Doc' w
pcat SigLevel -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow [SigLevel]
l00, ([SigLevel], Edge, [SigLevel])
-> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. b -> Either a b
Right ([SigLevel]
l01, Edge
e, [SigLevel]
l1))
            (Right Int
w, Right ([], Edge
e, [SigLevel]
l1)) ->
              (Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Edge -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Edge
e Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Bool -> Doc' ()
pift Doc' ()
forall w. Doc' w
sp3 (Edge -> Int
forall {a}. Num a => Edge -> a
edgeprintsize Edge
e Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
w), [SigLevel] -> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. a -> Either a b
Left [SigLevel]
l1)
            (Right Int
w, Right (SigLevel
h : [SigLevel]
t, Edge
e, [SigLevel]
l')) -> (Doc' ()
d Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> SigLevel -> Int -> Doc' ()
forall {a} {a}. (Show a, Eq a, Num a) => a -> a -> Doc' ()
prettylevelwithwidth SigLevel
h Int
w, ([SigLevel], Edge, [SigLevel])
-> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. b -> Either a b
Right ([SigLevel]
t, Edge
e, [SigLevel]
l'))
        )
        (Doc' ()
forall a. Monoid a => a
mempty, case SeqIn
si of SIComb NonEmpty SigLevel
l -> [SigLevel] -> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. a -> Either a b
Left ([SigLevel] -> Either [SigLevel] ([SigLevel], Edge, [SigLevel]))
-> [SigLevel] -> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. (a -> b) -> a -> b
$ NonEmpty SigLevel -> [SigLevel]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty SigLevel
l; SISeq [SigLevel]
a Edge
b [SigLevel]
c -> ([SigLevel], Edge, [SigLevel])
-> Either [SigLevel] ([SigLevel], Edge, [SigLevel])
forall a b. b -> Either a b
Right ([SigLevel]
a, Edge
b, [SigLevel]
c))
        [Either Int Int]
l
  where
    edgeprintsize :: Edge -> a
edgeprintsize Edge
x = case Edge
x of EdgePos_neg Bool
_ -> a
1; EdgeDesc SigLevel
_ SigLevel
_ -> a
4
    sp3 :: Doc' w
sp3 = ByteString -> Doc' w
forall w. ByteString -> Doc' w
raw ByteString
"   "
    prettylevelwithwidth :: a -> a -> Doc' ()
prettylevelwithwidth a
l a
w = a -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow a
l Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Bool -> Doc' ()
pift Doc' ()
forall w. Doc' w
sp3 (a
w a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
4)
    

-- | Prints a table in a singular block with aligned columns, or just prints it if not possible
prettySeqRows :: NonEmpty SeqRow -> Print
prettySeqRows :: NonEmpty SeqRow -> Reader PrintingOpts (Doc' ())
prettySeqRows NonEmpty SeqRow
l = do
  Bool
ts <- (PrintingOpts -> Bool) -> ReaderT PrintingOpts Identity Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PrintingOpts -> Bool
_poTableSpace
  let
    pp :: (Foldable t, Show x) => t x -> Doc
    pp :: forall (t :: * -> *) x. (Foldable t, Show x) => t x -> Doc' ()
pp t x
l =
      ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw (ByteString -> Doc' ()) -> ByteString -> Doc' ()
forall a b. (a -> b) -> a -> b
$
        String -> ByteString
forall a. IsString a => String -> a
fromString (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
$
          if Bool
ts then String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" " ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ (x -> String) -> [x] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map x -> String
forall a. Show a => a -> String
show ([x] -> [String]) -> [x] -> [String]
forall a b. (a -> b) -> a -> b
$ t x -> [x]
forall a. t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t x
l
          else (x -> String) -> t x -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap x -> String
forall a. Show a => a -> String
show t x
l
    psi :: SeqIn -> Doc' ()
psi SeqIn
x = case SeqIn
x of
      SIComb NonEmpty SigLevel
l -> NonEmpty SigLevel -> Doc' ()
forall (t :: * -> *) x. (Foldable t, Show x) => t x -> Doc' ()
pp NonEmpty SigLevel
l
      SISeq [SigLevel]
l0 Edge
e [SigLevel]
l1 -> [SigLevel] -> Doc' ()
forall (t :: * -> *) x. (Foldable t, Show x) => t x -> Doc' ()
pp [SigLevel]
l0 Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Edge -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow Edge
e Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> [SigLevel] -> Doc' ()
forall (t :: * -> *) x. (Foldable t, Show x) => t x -> Doc' ()
pp [SigLevel]
l1
  (Doc' () -> Doc' () -> Doc' ())
-> (SeqRow -> Reader PrintingOpts (Doc' ()))
-> NonEmpty SeqRow
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl
    Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>)
    ( case NonEmpty SeqRow -> [Either Int Int]
seqrowAlignment NonEmpty SeqRow
l of
        -- fallback prettyprinting because aligned is better but not always possible
        [] -> \(SeqRow SeqIn
si SigLevel
s Maybe ZOX
ns) -> Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ SeqIn -> Doc' ()
psi SeqIn
si Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> SigLevel -> Maybe ZOX -> Doc' ()
forall {w} {a} {a}.
(Ord w, Semigroup w, Enum w, Show a, Show a) =>
a -> Maybe a -> Doc' w
prettyend SigLevel
s Maybe ZOX
ns
        -- aligned prettyprinting
        [Either Int Int]
colws -> \(SeqRow SeqIn
si SigLevel
s Maybe ZOX
ns) -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> SigLevel -> Maybe ZOX -> Doc' ()
forall {w} {a} {a}.
(Ord w, Semigroup w, Enum w, Show a, Show a) =>
a -> Maybe a -> Doc' w
prettyend SigLevel
s Maybe ZOX
ns) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SeqIn -> [Either Int Int] -> Reader PrintingOpts (Doc' ())
prettySeqIn SeqIn
si [Either Int Int]
colws
    )
    NonEmpty SeqRow
l
  where
    prettyend :: a -> Maybe a -> Doc' w
prettyend a
s Maybe a
ns = Doc' w -> Doc' w
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' w
forall w. Doc' w
colon Doc' w -> Doc' w -> Doc' w
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> a -> Doc' w
forall a w. Show a => a -> Doc' w
viaShow a
s Doc' w -> Doc' w -> Doc' w
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' w
forall w. Doc' w
colon Doc' w -> Doc' w -> Doc' w
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> Doc' w -> (a -> Doc' w) -> Maybe a -> Doc' w
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc' w
"-" a -> Doc' w
forall a w. Show a => a -> Doc' w
viaShow Maybe a
ns) Doc' w -> Doc' w -> Doc' w
forall a. Semigroup a => a -> a -> a
<> Doc' w
forall w. Doc' w
semi

prettyPrimTable :: Doc -> PrimTable -> Print
prettyPrimTable :: Doc' () -> PrimTable -> Reader PrintingOpts (Doc' ())
prettyPrimTable Doc' ()
od PrimTable
b = case PrimTable
b of
  CombTable NonEmpty CombRow
l -> do
    Bool
ts <- (PrintingOpts -> Bool) -> ReaderT PrintingOpts Identity Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PrintingOpts -> Bool
_poTableSpace
    let
      pp :: t a -> String
pp t a
l =
        if Bool
ts then String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" " ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ (a -> String) -> [a] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map a -> String
forall a. Show a => a -> String
show ([a] -> [String]) -> [a] -> [String]
forall a b. (a -> b) -> a -> b
$ t a -> [a]
forall a. t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t a
l
        else (a -> String) -> t a -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap a -> String
forall a. Show a => a -> String
show t a
l
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
      Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block Doc' ()
"table" Doc' ()
"endtable" (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$
        (\CombRow -> Doc' ()
f -> (CombRow -> Doc' ())
-> (CombRow -> Doc' () -> Doc' ()) -> NonEmpty CombRow -> Doc' ()
forall a b. (a -> b) -> (a -> b -> b) -> NonEmpty a -> b
foldrMap1 CombRow -> Doc' ()
f (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) (Doc' () -> Doc' () -> Doc' ())
-> (CombRow -> Doc' ()) -> CombRow -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CombRow -> Doc' ()
f))
          (\(CombRow NonEmpty SigLevel
i ZOX
o) -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ ByteString -> Doc' ()
forall w. ByteString -> Doc' w
raw (String -> ByteString
forall a. IsString a => String -> a
fromString (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
$ NonEmpty SigLevel -> String
forall {a} {t :: * -> *}. (Show a, Foldable t) => t a -> String
pp NonEmpty SigLevel
i) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
forall w. Doc' w
colon Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> ZOX -> Doc' ()
forall a w. Show a => a -> Doc' w
viaShow ZOX
o Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi)
          NonEmpty CombRow
l
  SeqTable Maybe ZOX
mi NonEmpty SeqRow
l -> do
    Doc' ()
table <- NonEmpty SeqRow -> Reader PrintingOpts (Doc' ())
prettySeqRows NonEmpty SeqRow
l
    let pinit :: ZOX -> a
pinit ZOX
iv = case ZOX
iv of ZOX
ZOXX -> a
"1'bx"; ZOX
ZOXZ -> a
"0"; ZOX
ZOXO -> a
"1"
    Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
      Doc' () -> (ZOX -> Doc' ()) -> Maybe ZOX -> Doc' ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc' ()
forall a. Monoid a => a
mempty (\ZOX
iv -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' ()
"initial" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
od) Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
forall w. Doc' w
equals Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<+> ZOX -> Doc' ()
forall {a}. IsString a => ZOX -> a
pinit ZOX
iv Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) Maybe ZOX
mi
        Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block Doc' ()
"table" Doc' ()
"endtable" Doc' ()
table

prettyPrimitiveBlock :: PrimitiveBlock -> Print
prettyPrimitiveBlock :: PrimitiveBlock -> Reader PrintingOpts (Doc' ())
prettyPrimitiveBlock (PrimitiveBlock Attributes
a Identifier
s Identifier
o NonEmpty Identifier
i NonEmpty (AttrIded PrimPort)
pd PrimTable
b) = do
  (Doc' ()
od, Doc' ()
ol) <- PrettyIdent Identifier
prettyIdent Identifier
o
  Doc' ()
head <- (Doc' () -> Doc' ())
-> PrettyIdent Identifier
-> Identifier
-> Reader PrintingOpts (Doc' ())
forall a.
(Doc' () -> Doc' ())
-> PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
fpadj (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
group (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' ()
"primitive" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>)) PrettyIdent Identifier
prettyIdent Identifier
s
  Doc' ()
ports <- PrettyIdent (NonEmpty Identifier)
-> NonEmpty Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj (PrettyIdent Identifier -> PrettyIdent (NonEmpty Identifier)
forall a. PrettyIdent a -> PrettyIdent (NonEmpty a)
cslid1 PrettyIdent Identifier
prettyIdent) NonEmpty Identifier
i
  Doc' ()
header <- Attributes -> Doc' () -> Reader PrintingOpts (Doc' ())
prettyItem Attributes
a (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' ()
head Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Doc' ()
gpar (Doc' ()
od Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
ol Doc' () -> Doc' () -> Doc' ()
<.> Doc' ()
ports)
  Doc' ()
table <- Doc' () -> PrimTable -> Reader PrintingOpts (Doc' ())
prettyPrimTable Doc' ()
od PrimTable
b
  Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block Doc' ()
header Doc' ()
"endprimitive" (Doc' () -> Doc' ()) -> (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' ()
table)
    (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Doc' () -> Doc' () -> Doc' ())
-> ((Attributes, PrimPort, NonEmpty Identifier)
    -> Reader PrintingOpts (Doc' ()))
-> (AttrIded PrimPort
    -> (Attributes, PrimPort, NonEmpty Identifier))
-> (AttrIded PrimPort
    -> (Attributes, PrimPort, NonEmpty Identifier)
    -> Maybe (Attributes, PrimPort, NonEmpty Identifier))
-> NonEmpty (AttrIded PrimPort)
-> Reader PrintingOpts (Doc' ())
forall y x.
(Doc' () -> Doc' () -> Doc' ())
-> (y -> Reader PrintingOpts (Doc' ()))
-> (x -> y)
-> (x -> y -> Maybe y)
-> NonEmpty x
-> Reader PrintingOpts (Doc' ())
prettyregroup
      Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>)
      (Attributes, PrimPort, NonEmpty Identifier)
-> Reader PrintingOpts (Doc' ())
prettyPrimPorts
      (\(AttrIded Attributes
a Identifier
i PrimPort
p) -> (Attributes
a, PrimPort
p, [Item (NonEmpty Identifier)
Identifier
i]))
      ( \(AttrIded Attributes
na Identifier
i PrimPort
np) (Attributes
a, PrimPort
p, NonEmpty Identifier
l) -> case (PrimPort
np, PrimPort
p) of
          (PrimPort
PPInput, PrimPort
PPInput) | Attributes
na Attributes -> Attributes -> Bool
forall a. Eq a => a -> a -> Bool
== Attributes
a -> (Attributes, PrimPort, NonEmpty Identifier)
-> Maybe (Attributes, PrimPort, NonEmpty Identifier)
forall a. a -> Maybe a
Just (Attributes
a, PrimPort
p, Identifier
i Identifier -> NonEmpty Identifier -> NonEmpty Identifier
forall a. a -> NonEmpty a -> NonEmpty a
<| NonEmpty Identifier
l)
          (PrimPort, PrimPort)
_ -> Maybe (Attributes, PrimPort, NonEmpty Identifier)
forall a. Maybe a
Nothing
      )
      NonEmpty (AttrIded PrimPort)
pd

prettyConfigItem :: ConfigItem -> Print
prettyConfigItem :: ConfigItem -> Reader PrintingOpts (Doc' ())
prettyConfigItem (ConfigItem Cell_inst
ci LLU
llu) = do
  Doc' ()
dci <- case Cell_inst
ci of
    CICell Dot1Ident
c -> (Doc' ()
"cell" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>) (Doc' () -> Doc' ())
-> ((Doc' (), Doc' ()) -> Doc' ()) -> (Doc' (), Doc' ()) -> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst ((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Dot1Ident
prettyDot1Ident Dot1Ident
c
    CIInst NonEmpty Identifier
i ->
      (Doc' ()
"instance" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=>)
        (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Identifier -> Reader PrintingOpts (Doc' ()))
-> (Identifier
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> NonEmpty Identifier
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> (a -> b -> b) -> NonEmpty a -> b
foldrMap1 (((Doc' (), Doc' ()) -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b.
(a -> b)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent Identifier
-> Identifier
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Identifier
prettyIdent) ((Doc' () -> Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (\Doc' ()
a Doc' ()
b -> Doc' ()
a Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
dot Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
b) (Reader PrintingOpts (Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> (Identifier -> Reader PrintingOpts (Doc' ()))
-> Identifier
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent) NonEmpty Identifier
i
  Doc' ()
dllu <- case LLU
llu of
    LLULiblist [ByteString]
ls -> (Doc' ()
"liblist" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=>) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent ByteString
-> [ByteString] -> Reader PrintingOpts (Doc' ())
forall {a}. PrettyIdent a -> [a] -> Reader PrintingOpts (Doc' ())
catid PrettyIdent ByteString
prettyBS [ByteString]
ls
    LLUUse Dot1Ident
s Bool
c -> (\Doc' ()
x -> Doc' ()
"use" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
x Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' () -> Bool -> Doc' ()
pift Doc' ()
":config" Bool
c) (Doc' () -> Doc' ())
-> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyIdent Dot1Ident -> Dot1Ident -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Dot1Ident
prettyDot1Ident Dot1Ident
s
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
dci Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
ng Doc' ()
dllu Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
  where
    catid :: PrettyIdent a -> [a] -> Reader PrintingOpts (Doc' ())
catid PrettyIdent a
f = Reader PrintingOpts (Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (a -> b) -> (a -> b -> b) -> [a] -> b
foldrMap1' (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) (PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent a
f) ((a
  -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
 -> [a] -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ((Doc' (), Doc' ()) -> Doc' () -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<=>) (Doc' () -> Doc' () -> Doc' ())
-> ((Doc' (), Doc' ()) -> Doc' ())
-> (Doc' (), Doc' ())
-> Doc' ()
-> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent a
-> a
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent a
f

prettyConfigBlock :: ConfigBlock -> Print
prettyConfigBlock :: ConfigBlock -> Reader PrintingOpts (Doc' ())
prettyConfigBlock (ConfigBlock Identifier
i [Dot1Ident]
des [ConfigItem]
b [ByteString]
def) = do
  Doc' ()
di <- PrettyIdent Identifier
-> Identifier -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
padj PrettyIdent Identifier
prettyIdent Identifier
i
  Doc' ()
design <- PrettyIdent Dot1Ident
-> [Dot1Ident] -> Reader PrintingOpts (Doc' ())
forall {a}. PrettyIdent a -> [a] -> Reader PrintingOpts (Doc' ())
catid PrettyIdent Dot1Ident
prettyDot1Ident [Dot1Ident]
des
  Doc' ()
body <- (Doc' () -> Doc' () -> Doc' ())
-> (ConfigItem -> Reader PrintingOpts (Doc' ()))
-> [ConfigItem]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<#>) ConfigItem -> Reader PrintingOpts (Doc' ())
prettyConfigItem [ConfigItem]
b
  Doc' ()
dft <- PrettyIdent ByteString
-> [ByteString] -> Reader PrintingOpts (Doc' ())
forall {a}. PrettyIdent a -> [a] -> Reader PrintingOpts (Doc' ())
catid PrettyIdent ByteString
prettyBS [ByteString]
def
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$
    Doc' () -> Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w -> Doc' w
block (Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ Doc' ()
"config" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<=> Doc' ()
di Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi) Doc' ()
"endconfig" (Doc' () -> Doc' ()) -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$
      Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' ()
"design" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
design) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' ()
body Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?#> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w
nest (Doc' ()
"default liblist" Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<?=> Doc' ()
dft) Doc' () -> Doc' () -> Doc' ()
forall a. Semigroup a => a -> a -> a
<> Doc' ()
forall w. Doc' w
semi
  where
    catid :: PrettyIdent a -> [a] -> Reader PrintingOpts (Doc' ())
catid PrettyIdent a
f = Reader PrintingOpts (Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall b a. b -> (a -> b) -> (a -> b -> b) -> [a] -> b
foldrMap1' (Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc' ()
forall a. Monoid a => a
mempty) (PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
forall a. PrettyIdent a -> a -> Reader PrintingOpts (Doc' ())
gpadj PrettyIdent a
f) ((a
  -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
 -> [a] -> Reader PrintingOpts (Doc' ()))
-> (a
    -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> [a]
-> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ ((Doc' (), Doc' ()) -> Doc' () -> Doc' ())
-> ReaderT PrintingOpts Identity (Doc' (), Doc' ())
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall a b c.
(a -> b -> c)
-> ReaderT PrintingOpts Identity a
-> ReaderT PrintingOpts Identity b
-> ReaderT PrintingOpts Identity c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
(<=>) (Doc' () -> Doc' () -> Doc' ())
-> ((Doc' (), Doc' ()) -> Doc' ())
-> (Doc' (), Doc' ())
-> Doc' ()
-> Doc' ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Doc' (), Doc' ()) -> Doc' ()
forall a b. (a, b) -> a
fst) (ReaderT PrintingOpts Identity (Doc' (), Doc' ())
 -> Reader PrintingOpts (Doc' ()) -> Reader PrintingOpts (Doc' ()))
-> PrettyIdent a
-> a
-> Reader PrintingOpts (Doc' ())
-> Reader PrintingOpts (Doc' ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyIdent a
f

prettyVerilog2005 :: Verilog2005 -> Print
prettyVerilog2005 :: Verilog2005 -> Reader PrintingOpts (Doc' ())
prettyVerilog2005 (Verilog2005 [ModuleBlock]
mb [PrimitiveBlock]
pb [ConfigBlock]
cb) = do
  (Doc' (), LocalCompDir)
mods <-
    (Reader PrintingOpts (Doc' (), LocalCompDir)
 -> ModuleBlock -> Reader PrintingOpts (Doc' (), LocalCompDir))
-> Reader PrintingOpts (Doc' (), LocalCompDir)
-> [ModuleBlock]
-> Reader PrintingOpts (Doc' (), LocalCompDir)
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl'
      ( \Reader PrintingOpts (Doc' (), LocalCompDir)
macc ModuleBlock
m -> do
          (Doc' ()
d, LocalCompDir
lcd) <- Reader PrintingOpts (Doc' (), LocalCompDir)
macc
          (Doc' () -> Doc' ())
-> (Doc' (), LocalCompDir) -> (Doc' (), LocalCompDir)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Doc' ()
d Doc' () -> Doc' () -> Doc' ()
<##>) ((Doc' (), LocalCompDir) -> (Doc' (), LocalCompDir))
-> Reader PrintingOpts (Doc' (), LocalCompDir)
-> Reader PrintingOpts (Doc' (), LocalCompDir)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LocalCompDir
-> ModuleBlock -> Reader PrintingOpts (Doc' (), LocalCompDir)
prettyModuleBlock LocalCompDir
lcd ModuleBlock
m
      )
      ((Doc' (), LocalCompDir)
-> Reader PrintingOpts (Doc' (), LocalCompDir)
forall a. a -> ReaderT PrintingOpts Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc' ()
forall a. Monoid a => a
mempty, LocalCompDir
lcdDefault))
      [ModuleBlock]
mb
  Doc' ()
prims <- (Doc' () -> Doc' () -> Doc' ())
-> (PrimitiveBlock -> Reader PrintingOpts (Doc' ()))
-> [PrimitiveBlock]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
(<##>) PrimitiveBlock -> Reader PrintingOpts (Doc' ())
prettyPrimitiveBlock [PrimitiveBlock]
pb
  Doc' ()
confs <- (Doc' () -> Doc' () -> Doc' ())
-> (ConfigBlock -> Reader PrintingOpts (Doc' ()))
-> [ConfigBlock]
-> Reader PrintingOpts (Doc' ())
forall (f :: * -> *) a.
Foldable f =>
(Doc' () -> Doc' () -> Doc' ())
-> (a -> Reader PrintingOpts (Doc' ()))
-> f a
-> Reader PrintingOpts (Doc' ())
pl Doc' () -> Doc' () -> Doc' ()
(<##>) ConfigBlock -> Reader PrintingOpts (Doc' ())
prettyConfigBlock [ConfigBlock]
cb
  Doc' () -> Reader PrintingOpts (Doc' ())
forall a. a -> ReaderT PrintingOpts Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc' () -> Reader PrintingOpts (Doc' ()))
-> Doc' () -> Reader PrintingOpts (Doc' ())
forall a b. (a -> b) -> a -> b
$ (Doc' (), LocalCompDir) -> Doc' ()
forall a b. (a, b) -> a
fst (Doc' (), LocalCompDir)
mods Doc' () -> Doc' () -> Doc' ()
<##> Doc' ()
prims Doc' () -> Doc' () -> Doc' ()
<##> Doc' ()
confs
  where
    <##> :: Doc' () -> Doc' () -> Doc' ()
(<##>) = (Doc' () -> Doc' () -> Doc' ()) -> Doc' () -> Doc' () -> Doc' ()
forall w.
(Doc' w -> Doc' w -> Doc' w) -> Doc' w -> Doc' w -> Doc' w
mkopt ((Doc' () -> Doc' () -> Doc' ()) -> Doc' () -> Doc' () -> Doc' ())
-> (Doc' () -> Doc' () -> Doc' ()) -> Doc' () -> Doc' () -> Doc' ()
forall a b. (a -> b) -> a -> b
$ \Doc' ()
a Doc' ()
b -> Doc' ()
a Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' ()
forall a. Monoid a => a
mempty Doc' () -> Doc' () -> Doc' ()
forall w. DocLength w => Doc' w -> Doc' w -> Doc' w
<#> Doc' ()
b