    {-# OPTIONS_GHC -fno-warn-orphans #-}

    -- | Futhark prettyprinter.  This module defines 'Pretty' instances
    -- for the AST defined in "Futhark.IR.Syntax",
    -- but also a number of convenience functions if you don't want to use
    -- the interface from 'Pretty'.
    module Futhark.IR.Pretty
      ( prettyTuple,
        prettyTupleLines,
        prettyString,
        PrettyRep (..),
      )
    where

    import Data.Foldable (toList)
    import Data.List.NonEmpty (NonEmpty (..))
    import Data.Maybe
    import Futhark.IR.Syntax
    import Futhark.Util.Pretty

    -- | The class of representations whose annotations can be prettyprinted.
    class
      ( RepTypes rep,
        Pretty (RetType rep),
        Pretty (BranchType rep),
        Pretty (FParamInfo rep),
        Pretty (LParamInfo rep),
        Pretty (LetDec rep),
        Pretty (Op rep)
      ) =>
      PrettyRep rep
      where
      ppExpDec :: ExpDec rep -> Exp rep -> Maybe (Doc a)
      ppExpDec ExpDec rep
    _ Exp rep
    _ = Maybe (Doc a)
    forall a. Maybe a
    Nothing

    instance Pretty (NoOp rep) where
      pretty :: forall ann. NoOp rep -> Doc ann
    pretty NoOp rep
    NoOp = Doc ann
    "noop"

    instance Pretty VName where
      pretty :: forall ann. VName -> Doc ann
    pretty (VName Name
    vn Int
    i) = Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    vn Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "_" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Int -> String
    forall a. Show a => a -> String
    show Int
    i)

    instance Pretty Commutativity where
      pretty :: forall ann. Commutativity -> Doc ann
    pretty Commutativity
    Commutative = Doc ann
    "commutative"
      pretty Commutativity
    Noncommutative = Doc ann
    "noncommutative"

    instance Pretty Shape where
      pretty :: forall ann. Shape -> Doc ann
    pretty = [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat ([Doc ann] -> Doc ann) -> (Shape -> [Doc ann]) -> Shape -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> (SubExp -> Doc ann) -> SubExp -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty) ([SubExp] -> [Doc ann])
    -> (Shape -> [SubExp]) -> Shape -> [Doc ann]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Shape -> [SubExp]
    forall d. ShapeBase d -> [d]
    shapeDims

    instance Pretty Rank where
      pretty :: forall ann. Rank -> Doc ann
    pretty (Rank Int
    r) = [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Int -> Doc ann -> [Doc ann]
    forall a. Int -> a -> [a]
    replicate Int
    r Doc ann
    "[]"

    instance (Pretty a) => Pretty (Ext a) where
      pretty :: forall ann. Ext a -> Doc ann
    pretty (Free a
    e) = a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    e
      pretty (Ext Int
    x) = Doc ann
    "?" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Int -> String
    forall a. Show a => a -> String
    show Int
    x)

    instance Pretty ExtShape where
      pretty :: forall ann. ExtShape -> Doc ann
    pretty = [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat ([Doc ann] -> Doc ann)
    -> (ExtShape -> [Doc ann]) -> ExtShape -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (ExtSize -> Doc ann) -> [ExtSize] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> (ExtSize -> Doc ann) -> ExtSize -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ExtSize -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ExtSize -> Doc ann
    pretty) ([ExtSize] -> [Doc ann])
    -> (ExtShape -> [ExtSize]) -> ExtShape -> [Doc ann]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ExtShape -> [ExtSize]
    forall d. ShapeBase d -> [d]
    shapeDims

    instance Pretty Space where
      pretty :: forall ann. Space -> Doc ann
    pretty Space
    DefaultSpace = Doc ann
    forall a. Monoid a => a
    mempty
      pretty (Space String
    s) = Doc ann
    "@" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    s
      pretty (ScalarSpace [SubExp]
    d PrimType
    t) = Doc ann
    "@" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat ((SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> (SubExp -> Doc ann) -> SubExp -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty) [SubExp]
    d) Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t

    instance (Pretty u) => Pretty (TypeBase Shape u) where
      pretty :: forall ann. TypeBase Shape u -> Doc ann
    pretty (Prim PrimType
    t) = PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t
      pretty (Acc VName
    acc Shape
    ispace [Type]
    ts u
    u) =
        u -> Doc ann
    forall ann. u -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty u
    u
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "acc"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply
            [ VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    acc,
              Shape -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Shape -> Doc ann
    pretty Shape
    ispace,
              [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Type -> Doc ann) -> [Type] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Type -> Doc ann
    pretty [Type]
    ts
            ]
      pretty (Array PrimType
    et (Shape [SubExp]
    ds) u
    u) =
        u -> Doc ann
    forall ann. u -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty u
    u Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat ((SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> (SubExp -> Doc ann) -> SubExp -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty) [SubExp]
    ds) Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    et
      pretty (Mem Space
    s) = Doc ann
    "mem" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Space -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Space -> Doc ann
    pretty Space
    s

    instance (Pretty u) => Pretty (TypeBase ExtShape u) where
      pretty :: forall ann. TypeBase ExtShape u -> Doc ann
    pretty (Prim PrimType
    t) = PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t
      pretty (Acc VName
    acc Shape
    ispace [Type]
    ts u
    u) =
        u -> Doc ann
    forall ann. u -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty u
    u
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "acc"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply
            [ VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    acc,
              Shape -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Shape -> Doc ann
    pretty Shape
    ispace,
              [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Type -> Doc ann) -> [Type] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Type -> Doc ann
    pretty [Type]
    ts
            ]
      pretty (Array PrimType
    et (Shape [ExtSize]
    ds) u
    u) =
        u -> Doc ann
    forall ann. u -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty u
    u Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat ((ExtSize -> Doc ann) -> [ExtSize] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> (ExtSize -> Doc ann) -> ExtSize -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ExtSize -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ExtSize -> Doc ann
    pretty) [ExtSize]
    ds) Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    et
      pretty (Mem Space
    s) = Doc ann
    "mem" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Space -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Space -> Doc ann
    pretty Space
    s

    instance (Pretty u) => Pretty (TypeBase Rank u) where
      pretty :: forall ann. TypeBase Rank u -> Doc ann
    pretty (Prim PrimType
    t) = PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t
      pretty (Acc VName
    acc Shape
    ispace [Type]
    ts u
    u) =
        u -> Doc ann
    forall ann. u -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty u
    u
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "acc"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply
            [ VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    acc,
              Shape -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Shape -> Doc ann
    pretty Shape
    ispace,
              [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Type -> Doc ann) -> [Type] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Type -> Doc ann
    pretty [Type]
    ts
            ]
      pretty (Array PrimType
    et (Rank Int
    n) u
    u) =
        u -> Doc ann
    forall ann. u -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty u
    u Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat (Int -> Doc ann -> [Doc ann]
    forall a. Int -> a -> [a]
    replicate Int
    n (Doc ann -> [Doc ann]) -> Doc ann -> [Doc ann]
    forall a b. (a -> b) -> a -> b
    $ Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets Doc ann
    forall a. Monoid a => a
    mempty) Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    et
      pretty (Mem Space
    s) = Doc ann
    "mem" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Space -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Space -> Doc ann
    pretty Space
    s

    instance Pretty Ident where
      pretty :: forall ann. Ident -> Doc ann
    pretty Ident
    ident = Type -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Type -> Doc ann
    pretty (Ident -> Type
    identType Ident
    ident) Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty (Ident -> VName
    identName Ident
    ident)

    instance Pretty SubExp where
      pretty :: forall ann. SubExp -> Doc ann
    pretty (Var VName
    v) = VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    v
      pretty (Constant PrimValue
    v) = PrimValue -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimValue -> Doc ann
    pretty PrimValue
    v

    instance Pretty Certs where
      pretty :: forall ann. Certs -> Doc ann
    pretty (Certs []) = Doc ann
    forall a. Monoid a => a
    mempty
      pretty (Certs [VName]
    cs) = Doc ann
    "#" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ((VName -> Doc ann) -> [VName] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty [VName]
    cs))

    instance (PrettyRep rep) => Pretty (Stms rep) where
      pretty :: forall ann. Stms rep -> Doc ann
    pretty = [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann)
    -> (Stms rep -> [Doc ann]) -> Stms rep -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Stm rep -> Doc ann) -> [Stm rep] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Stm rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Stm rep -> Doc ann
    pretty ([Stm rep] -> [Doc ann])
    -> (Stms rep -> [Stm rep]) -> Stms rep -> [Doc ann]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Stms rep -> [Stm rep]
    forall rep. Stms rep -> [Stm rep]
    stmsToList

    instance Pretty SubExpRes where
      pretty :: forall ann. SubExpRes -> Doc ann
    pretty (SubExpRes Certs
    cs SubExp
    se) = [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    hsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Certs -> [Doc ann]
    forall a. Certs -> [Doc a]
    certAnnots Certs
    cs [Doc ann] -> [Doc ann] -> [Doc ann]
    forall a. [a] -> [a] -> [a]
    ++ [SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    se]

    instance (PrettyRep rep) => Pretty (Body rep) where
      pretty :: forall ann. Body rep -> Doc ann
    pretty (Body BodyDec rep
    _ Stms rep
    stms [SubExpRes]
    res)
        | Stms rep -> Bool
    forall a. Seq a -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null Stms rep
    stms = Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (SubExpRes -> Doc ann) -> [SubExpRes] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExpRes -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExpRes -> Doc ann
    pretty [SubExpRes]
    res)
        | Bool
    otherwise =
            [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ((Stm rep -> Doc ann) -> [Stm rep] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Stm rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Stm rep -> Doc ann
    pretty ([Stm rep] -> [Doc ann]) -> [Stm rep] -> [Doc ann]
    forall a b. (a -> b) -> a -> b
    $ Stms rep -> [Stm rep]
    forall rep. Stms rep -> [Stm rep]
    stmsToList Stms rep
    stms)
              Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann
    "in"
              Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (SubExpRes -> Doc ann) -> [SubExpRes] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExpRes -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExpRes -> Doc ann
    pretty [SubExpRes]
    res)

    instance Pretty Attr where
      pretty :: forall ann. Attr -> Doc ann
    pretty (AttrName Name
    v) = Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    v
      pretty (AttrInt Integer
    x) = Integer -> Doc ann
    forall ann. Integer -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Integer
    x
      pretty (AttrComp Name
    f [Attr]
    attrs) = Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    f Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Attr -> Doc ann) -> [Attr] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Attr -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Attr -> Doc ann
    pretty [Attr]
    attrs)

    attrAnnots :: Attrs -> [Doc a]
    attrAnnots :: forall a. Attrs -> [Doc a]
    attrAnnots = (Attr -> Doc a) -> [Attr] -> [Doc a]
    forall a b. (a -> b) -> [a] -> [b]
    map Attr -> Doc a
    forall {a} {ann}. Pretty a => a -> Doc ann
    f ([Attr] -> [Doc a]) -> (Attrs -> [Attr]) -> Attrs -> [Doc a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Set Attr -> [Attr]
    forall a. Set a -> [a]
    forall (t :: * -> *) a. Foldable t => t a -> [a]
    toList (Set Attr -> [Attr]) -> (Attrs -> Set Attr) -> Attrs -> [Attr]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Attrs -> Set Attr
    unAttrs
      where
        f :: a -> Doc ann
    f a
    v = Doc ann
    "#[" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    v Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "]"

    stmAttrAnnots :: Stm rep -> [Doc a]
    stmAttrAnnots :: forall rep a. Stm rep -> [Doc a]
    stmAttrAnnots = Attrs -> [Doc a]
    forall a. Attrs -> [Doc a]
    attrAnnots (Attrs -> [Doc a]) -> (Stm rep -> Attrs) -> Stm rep -> [Doc a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . StmAux (ExpDec rep) -> Attrs
    forall dec. StmAux dec -> Attrs
    stmAuxAttrs (StmAux (ExpDec rep) -> Attrs)
    -> (Stm rep -> StmAux (ExpDec rep)) -> Stm rep -> Attrs
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Stm rep -> StmAux (ExpDec rep)
    forall rep. Stm rep -> StmAux (ExpDec rep)
    stmAux

    certAnnots :: Certs -> [Doc a]
    certAnnots :: forall a. Certs -> [Doc a]
    certAnnots Certs
    cs
      | Certs
    cs Certs -> Certs -> Bool
    forall a. Eq a => a -> a -> Bool
    == Certs
    forall a. Monoid a => a
    mempty = []
      | Bool
    otherwise = [Certs -> Doc a
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Certs -> Doc ann
    pretty Certs
    cs]

    stmCertAnnots :: Stm rep -> [Doc a]
    stmCertAnnots :: forall rep a. Stm rep -> [Doc a]
    stmCertAnnots = Certs -> [Doc a]
    forall a. Certs -> [Doc a]
    certAnnots (Certs -> [Doc a]) -> (Stm rep -> Certs) -> Stm rep -> [Doc a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . StmAux (ExpDec rep) -> Certs
    forall dec. StmAux dec -> Certs
    stmAuxCerts (StmAux (ExpDec rep) -> Certs)
    -> (Stm rep -> StmAux (ExpDec rep)) -> Stm rep -> Certs
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Stm rep -> StmAux (ExpDec rep)
    forall rep. Stm rep -> StmAux (ExpDec rep)
    stmAux

    instance Pretty Attrs where
      pretty :: forall ann. Attrs -> Doc ann
    pretty = [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    hsep ([Doc ann] -> Doc ann) -> (Attrs -> [Doc ann]) -> Attrs -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Attrs -> [Doc ann]
    forall a. Attrs -> [Doc a]
    attrAnnots

    instance (Pretty t) => Pretty (Pat t) where
      pretty :: forall ann. Pat t -> Doc ann
    pretty (Pat [PatElem t]
    xs) = Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commastack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (PatElem t -> Doc ann) -> [PatElem t] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map PatElem t -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PatElem t -> Doc ann
    pretty [PatElem t]
    xs

    instance (Pretty t) => Pretty (PatElem t) where
      pretty :: forall ann. PatElem t -> Doc ann
    pretty (PatElem VName
    name t
    t) = VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    name Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    colon Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (t -> Doc ann
    forall ann. t -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty t
    t)

    instance (Pretty t) => Pretty (Param t) where
      pretty :: forall ann. Param t -> Doc ann
    pretty (Param Attrs
    attrs VName
    name t
    t) =
        [Doc ann] -> Doc ann -> Doc ann
    forall a. [Doc a] -> Doc a -> Doc a
    annot (Attrs -> [Doc ann]
    forall a. Attrs -> [Doc a]
    attrAnnots Attrs
    attrs) (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    name Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    colon Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (t -> Doc ann
    forall ann. t -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty t
    t)

    instance (PrettyRep rep) => Pretty (Stm rep) where
      pretty :: forall ann. Stm rep -> Doc ann
    pretty stm :: Stm rep
    stm@(Let Pat (LetDec rep)
    pat StmAux (ExpDec rep)
    aux Exp rep
    e) =
        Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (Doc ann -> Doc ann) -> (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> Doc ann -> Doc ann
    forall ann. Int -> Doc ann -> Doc ann
    hang Int
    2 (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $
          Doc ann
    "let"
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (Pat (LetDec rep) -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Pat (LetDec rep) -> Doc ann
    pretty Pat (LetDec rep)
    pat)
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> case [Doc Any]
    forall {a}. [Doc a]
    stmannot of
              [] -> Doc ann
    forall ann. Doc ann
    equals Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Exp rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Exp rep -> Doc ann
    pretty Exp rep
    e
              [Doc Any]
    _ -> Doc ann
    forall ann. Doc ann
    equals Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack [Doc ann]
    forall {a}. [Doc a]
    stmannot Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Exp rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Exp rep -> Doc ann
    pretty Exp rep
    e)
        where
          stmannot :: [Doc a]
    stmannot =
            [[Doc a]] -> [Doc a]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat
              [ Maybe (Doc a) -> [Doc a]
    forall a. Maybe a -> [a]
    maybeToList (ExpDec rep -> Exp rep -> Maybe (Doc a)
    forall a. ExpDec rep -> Exp rep -> Maybe (Doc a)
    forall rep a.
    PrettyRep rep =>
    ExpDec rep -> Exp rep -> Maybe (Doc a)
    ppExpDec (StmAux (ExpDec rep) -> ExpDec rep
    forall dec. StmAux dec -> dec
    stmAuxDec StmAux (ExpDec rep)
    aux) Exp rep
    e),
                Stm rep -> [Doc a]
    forall rep a. Stm rep -> [Doc a]
    stmAttrAnnots Stm rep
    stm,
                Stm rep -> [Doc a]
    forall rep a. Stm rep -> [Doc a]
    stmCertAnnots Stm rep
    stm
              ]

    instance (Pretty a) => Pretty (Slice a) where
      pretty :: forall ann. Slice a -> Doc ann
    pretty (Slice [DimIndex a]
    xs) = Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ((DimIndex a -> Doc ann) -> [DimIndex a] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map DimIndex a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. DimIndex a -> Doc ann
    pretty [DimIndex a]
    xs))

    instance (Pretty d) => Pretty (FlatDimIndex d) where
      pretty :: forall ann. FlatDimIndex d -> Doc ann
    pretty (FlatDimIndex d
    n d
    s) = d -> Doc ann
    forall ann. d -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty d
    n Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    ":" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> d -> Doc ann
    forall ann. d -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty d
    s

    instance (Pretty a) => Pretty (FlatSlice a) where
      pretty :: forall ann. FlatSlice a -> Doc ann
    pretty (FlatSlice a
    offset [FlatDimIndex a]
    xs) = Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    offset Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    ";" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ((FlatDimIndex a -> Doc ann) -> [FlatDimIndex a] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map FlatDimIndex a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. FlatDimIndex a -> Doc ann
    pretty [FlatDimIndex a]
    xs))

    instance Pretty BasicOp where
      pretty :: forall ann. BasicOp -> Doc ann
    pretty (SubExp SubExp
    se) = SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    se
      pretty (Opaque OpaqueOp
    OpaqueNil SubExp
    e) = Doc ann
    "opaque" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    e]
      pretty (Opaque (OpaqueTrace Text
    s) SubExp
    e) = Doc ann
    "trace" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Text -> String
    forall a. Show a => a -> String
    show Text
    s), SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    e]
      pretty (ArrayLit [SubExp]
    es Type
    rt) =
        case Type
    rt of
          Array {} -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commastack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    es
          Type
    _ -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    es
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    colon
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "[]"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Type -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Type -> Doc ann
    pretty Type
    rt
      pretty (ArrayVal [PrimValue]
    vs PrimType
    t) =
        Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (PrimValue -> Doc ann) -> [PrimValue] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map PrimValue -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimValue -> Doc ann
    pretty [PrimValue]
    vs)
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    colon
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "[]"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t
      pretty (BinOp BinOp
    bop SubExp
    x SubExp
    y) = BinOp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. BinOp -> Doc ann
    pretty BinOp
    bop Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens (SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    x Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    y)
      pretty (CmpOp CmpOp
    op SubExp
    x SubExp
    y) = CmpOp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. CmpOp -> Doc ann
    pretty CmpOp
    op Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens (SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    x Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    y)
      pretty (ConvOp ConvOp
    conv SubExp
    x) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ConvOp -> String
    convOpFun ConvOp
    conv) Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    fromtype Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    x Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "to" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    totype
        where
          (PrimType
    fromtype, PrimType
    totype) = ConvOp -> (PrimType, PrimType)
    convOpType ConvOp
    conv
      pretty (UnOp UnOp
    op SubExp
    e) = UnOp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. UnOp -> Doc ann
    pretty UnOp
    op Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    e
      pretty (Index VName
    v Slice SubExp
    slice) = VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    v Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Slice SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Slice SubExp -> Doc ann
    pretty Slice SubExp
    slice
      pretty (Update Safety
    safety VName
    src Slice SubExp
    slice SubExp
    se) =
        VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    src Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    with Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Slice SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Slice SubExp -> Doc ann
    pretty Slice SubExp
    slice Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "=" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    se
        where
          with :: Doc ann
    with = case Safety
    safety of
            Safety
    Unsafe -> Doc ann
    "with"
            Safety
    Safe -> Doc ann
    "with?"
      pretty (FlatIndex VName
    v FlatSlice SubExp
    slice) = VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    v Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> FlatSlice SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. FlatSlice SubExp -> Doc ann
    pretty FlatSlice SubExp
    slice
      pretty (FlatUpdate VName
    src FlatSlice SubExp
    slice VName
    se) =
        VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    src Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "with" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> FlatSlice SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. FlatSlice SubExp -> Doc ann
    pretty FlatSlice SubExp
    slice Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "=" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    se
      pretty (Iota SubExp
    e SubExp
    x SubExp
    s IntType
    et) = Doc ann
    "iota" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    et' Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    e, SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    x, SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    s]
        where
          et' :: Doc ann
    et' = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (String -> Doc ann) -> String -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Int -> String
    forall a. Show a => a -> String
    show (Int -> String) -> Int -> String
    forall a b. (a -> b) -> a -> b
    $ PrimType -> Int
    primBitSize (PrimType -> Int) -> PrimType -> Int
    forall a b. (a -> b) -> a -> b
    $ IntType -> PrimType
    IntType IntType
    et
      pretty (Replicate (Shape []) SubExp
    e) = Doc ann
    "copy" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens (SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    e)
      pretty (Replicate Shape
    ne SubExp
    ve) =
        Doc ann
    "replicate" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [Shape -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Shape -> Doc ann
    pretty Shape
    ne, Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    ve)]
      pretty (Scratch PrimType
    t [SubExp]
    shape) =
        Doc ann
    "scratch" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply (PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : (SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    shape)
      pretty (Reshape ReshapeKind
    ReshapeArbitrary Shape
    shape VName
    e) =
        Doc ann
    "reshape" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [Shape -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Shape -> Doc ann
    pretty Shape
    shape, VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    e]
      pretty (Reshape ReshapeKind
    ReshapeCoerce Shape
    shape VName
    e) =
        Doc ann
    "coerce" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [Shape -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Shape -> Doc ann
    pretty Shape
    shape, VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    e]
      pretty (Rearrange [Int]
    perm VName
    e) =
        Doc ann
    "rearrange" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [[Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply ((Int -> Doc ann) -> [Int] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Int -> Doc ann
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [Int]
    perm), VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    e]
      pretty (Concat Int
    i (VName
    x :| [VName]
    xs) SubExp
    w) =
        Doc ann
    "concat" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "@" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Int -> Doc ann
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Int
    i Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply (SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    w Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    x Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : (VName -> Doc ann) -> [VName] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty [VName]
    xs)
      pretty (Manifest [Int]
    perm VName
    e) = Doc ann
    "manifest" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [[Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply ((Int -> Doc ann) -> [Int] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Int -> Doc ann
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [Int]
    perm), VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    e]
      pretty (Assert SubExp
    e ErrorMsg SubExp
    msg (SrcLoc
    loc, [SrcLoc]
    _)) =
        Doc ann
    "assert" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply [SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    e, ErrorMsg SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ErrorMsg SubExp -> Doc ann
    pretty ErrorMsg SubExp
    msg, String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (String -> Doc ann) -> String -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ String -> String
    forall a. Show a => a -> String
    show (String -> String) -> String -> String
    forall a b. (a -> b) -> a -> b
    $ SrcLoc -> String
    forall a. Located a => a -> String
    locStr SrcLoc
    loc]
      pretty (UpdateAcc Safety
    safety VName
    acc [SubExp]
    is [SubExp]
    v) =
        Doc ann
    update_acc_str
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply
            [ VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    acc,
              [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    is,
              [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    v
            ]
        where
          update_acc_str :: Doc ann
    update_acc_str = case Safety
    safety of
            Safety
    Safe -> Doc ann
    "update_acc"
            Safety
    Unsafe -> Doc ann
    "update_acc_unsafe"

    instance (Pretty a) => Pretty (ErrorMsg a) where
      pretty :: forall ann. ErrorMsg a -> Doc ann
    pretty (ErrorMsg [ErrorMsgPart a]
    parts) = Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (ErrorMsgPart a -> Doc ann) -> [ErrorMsgPart a] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map ErrorMsgPart a -> Doc ann
    forall {a} {ann}. Pretty a => ErrorMsgPart a -> Doc ann
    p [ErrorMsgPart a]
    parts
        where
          p :: ErrorMsgPart a -> Doc ann
    p (ErrorString Text
    s) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (String -> Doc ann) -> String -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    forall a. Show a => a -> String
    show Text
    s
          p (ErrorVal PrimType
    t a
    x) = a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    x Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    colon Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PrimType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimType -> Doc ann
    pretty PrimType
    t

    maybeNest :: (PrettyRep rep) => Body rep -> Doc a
    maybeNest :: forall rep a. PrettyRep rep => Body rep -> Doc a
    maybeNest Body rep
    b
      | Seq (Stm rep) -> Bool
    forall a. Seq a -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (Seq (Stm rep) -> Bool) -> Seq (Stm rep) -> Bool
    forall a b. (a -> b) -> a -> b
    $ Body rep -> Seq (Stm rep)
    forall rep. Body rep -> Stms rep
    bodyStms Body rep
    b = Body rep -> Doc a
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Body rep -> Doc ann
    pretty Body rep
    b
      | Bool
    otherwise = Doc a -> Doc a -> Doc a -> Doc a
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc a
    "{" Doc a
    "}" (Doc a -> Doc a) -> Doc a -> Doc a
    forall a b. (a -> b) -> a -> b
    $ Body rep -> Doc a
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Body rep -> Doc ann
    pretty Body rep
    b

    instance (PrettyRep rep) => Pretty (Case (Body rep)) where
      pretty :: forall ann. Case (Body rep) -> Doc ann
    pretty (Case [Maybe PrimValue]
    vs Body rep
    b) =
        Doc ann
    "case" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ((Maybe PrimValue -> Doc ann) -> [Maybe PrimValue] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> (PrimValue -> Doc ann) -> Maybe PrimValue -> Doc ann
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Doc ann
    "_" PrimValue -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PrimValue -> Doc ann
    pretty) [Maybe PrimValue]
    vs) Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "->" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Body rep -> Doc ann
    forall rep a. PrettyRep rep => Body rep -> Doc a
    maybeNest Body rep
    b

    prettyRet :: (Pretty t) => (t, RetAls) -> Doc a
    prettyRet :: forall t a. Pretty t => (t, RetAls) -> Doc a
    prettyRet (t
    t, RetAls [Int]
    pals [Int]
    rals)
      | [Int]
    pals [Int] -> [Int] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Int]
    forall a. Monoid a => a
    mempty,
        [Int]
    rals [Int] -> [Int] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Int]
    forall a. Monoid a => a
    mempty =
          t -> Doc a
    forall ann. t -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty t
    t
      | Bool
    otherwise =
          t -> Doc a
    forall ann. t -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty t
    t Doc a -> Doc a -> Doc a
    forall a. Semigroup a => a -> a -> a
    <> Doc a
    "#" Doc a -> Doc a -> Doc a
    forall a. Semigroup a => a -> a -> a
    <> Doc a -> Doc a
    forall ann. Doc ann -> Doc ann
    parens ([Int] -> Doc a
    forall {ann}. [Int] -> Doc ann
    pl [Int]
    pals Doc a -> Doc a -> Doc a
    forall a. Semigroup a => a -> a -> a
    <> Doc a
    forall ann. Doc ann
    comma Doc a -> Doc a -> Doc a
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Int] -> Doc a
    forall {ann}. [Int] -> Doc ann
    pl [Int]
    rals)
      where
        pl :: [Int] -> Doc ann
    pl = Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    brackets (Doc ann -> Doc ann) -> ([Int] -> Doc ann) -> [Int] -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> ([Int] -> [Doc ann]) -> [Int] -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Int -> Doc ann) -> [Int] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Int -> Doc ann
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty

    instance (PrettyRep rep) => Pretty (Exp rep) where
      pretty :: forall ann. Exp rep -> Doc ann
    pretty (Match [SubExp
    c] [Case [Just (BoolValue Bool
    True)] Body rep
    t] Body rep
    f (MatchDec [BranchType rep]
    ret MatchSort
    ifsort)) =
        Doc ann
    "if"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    info'
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    c
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann
    "then"
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Body rep -> Doc ann
    forall rep a. PrettyRep rep => Body rep -> Doc a
    maybeNest Body rep
    t
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "else"
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Body rep -> Doc ann
    forall rep a. PrettyRep rep => Body rep -> Doc a
    maybeNest Body rep
    f
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann
    forall ann. Doc ann
    colon
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTupleLines' ((BranchType rep -> Doc ann) -> [BranchType rep] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map BranchType rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. BranchType rep -> Doc ann
    pretty [BranchType rep]
    ret)
        where
          info' :: Doc ann
    info' = case MatchSort
    ifsort of
            MatchSort
    MatchNormal -> Doc ann
    forall a. Monoid a => a
    mempty
            MatchSort
    MatchFallback -> Doc ann
    " <fallback>"
            MatchSort
    MatchEquiv -> Doc ann
    " <equiv>"
      pretty (Match [SubExp]
    ses [Case (Body rep)]
    cs Body rep
    defb (MatchDec [BranchType rep]
    ret MatchSort
    ifsort)) =
        (Doc ann
    "match" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    info' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ((SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    ses))
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ((Case (Body rep) -> Doc ann) -> [Case (Body rep)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Case (Body rep) -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Case (Body rep) -> Doc ann
    pretty [Case (Body rep)]
    cs)
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann
    "default"
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "->"
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Body rep -> Doc ann
    forall rep a. PrettyRep rep => Body rep -> Doc a
    maybeNest Body rep
    defb
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann
    forall ann. Doc ann
    colon
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTupleLines' ((BranchType rep -> Doc ann) -> [BranchType rep] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map BranchType rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. BranchType rep -> Doc ann
    pretty [BranchType rep]
    ret)
        where
          info' :: Doc ann
    info' = case MatchSort
    ifsort of
            MatchSort
    MatchNormal -> Doc ann
    forall a. Monoid a => a
    mempty
            MatchSort
    MatchFallback -> Doc ann
    " <fallback>"
            MatchSort
    MatchEquiv -> Doc ann
    " <equiv>"
      pretty (BasicOp BasicOp
    op) = BasicOp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. BasicOp -> Doc ann
    pretty BasicOp
    op
      pretty (Apply Name
    fname [(SubExp, Diet)]
    args [(RetType rep, RetAls)]
    ret (Safety
    safety, SrcLoc
    _, [SrcLoc]
    _)) =
        Doc ann
    applykw
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Name -> String
    nameToString Name
    fname)
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    apply (((SubExp, Diet) -> Doc ann) -> [(SubExp, Diet)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (Doc ann -> Doc ann)
    -> ((SubExp, Diet) -> Doc ann) -> (SubExp, Diet) -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (SubExp, Diet) -> Doc ann
    forall {a} {ann}. Pretty a => (a, Diet) -> Doc ann
    prettyArg) [(SubExp, Diet)]
    args)
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann
    forall ann. Doc ann
    colon
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commasep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ ((RetType rep, RetAls) -> Doc ann)
    -> [(RetType rep, RetAls)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (RetType rep, RetAls) -> Doc ann
    forall t a. Pretty t => (t, RetAls) -> Doc a
    prettyRet [(RetType rep, RetAls)]
    ret)
        where
          prettyArg :: (a, Diet) -> Doc ann
    prettyArg (a
    arg, Diet
    Consume) = Doc ann
    "*" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    arg
          prettyArg (a
    arg, Diet
    _) = a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    arg
          applykw :: Doc ann
    applykw = case Safety
    safety of
            Safety
    Unsafe -> Doc ann
    "apply <unsafe>"
            Safety
    Safe -> Doc ann
    "apply"
      pretty (Op Op rep
    op) = Op rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Op rep -> Doc ann
    pretty Op rep
    op
      pretty (Loop [(Param (FParamInfo rep), SubExp)]
    merge LoopForm
    form Body rep
    loopbody) =
        Doc ann
    "loop"
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commastack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Param (FParamInfo rep) -> Doc ann)
    -> [Param (FParamInfo rep)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Param (FParamInfo rep) -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Param (FParamInfo rep) -> Doc ann
    pretty [Param (FParamInfo rep)]
    params)
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    equals
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ((SubExp -> Doc ann) -> [SubExp] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty [SubExp]
    args)
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> ( case LoopForm
    form of
                  ForLoop VName
    i IntType
    it SubExp
    bound ->
                    Doc ann
    "for"
                      Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align
                        ( VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    i
                            Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    ":"
                            Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> IntType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. IntType -> Doc ann
    pretty IntType
    it
                              Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "<"
                              Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align (SubExp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SubExp -> Doc ann
    pretty SubExp
    bound)
                        )
                  WhileLoop VName
    cond ->
                    Doc ann
    "while" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> VName -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. VName -> Doc ann
    pretty VName
    cond
              )
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "do"
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" (Body rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Body rep -> Doc ann
    pretty Body rep
    loopbody)
        where
          ([Param (FParamInfo rep)]
    params, [SubExp]
    args) = [(Param (FParamInfo rep), SubExp)]
    -> ([Param (FParamInfo rep)], [SubExp])
    forall a b. [(a, b)] -> ([a], [b])
    unzip [(Param (FParamInfo rep), SubExp)]
    merge
      pretty (WithAcc [WithAccInput rep]
    inputs Lambda rep
    lam) =
        Doc ann
    "with_acc"
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commastack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (WithAccInput rep -> Doc ann) -> [WithAccInput rep] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map WithAccInput rep -> Doc ann
    forall {a} {a} {a} {a} {ann}.
    (Pretty a, Pretty a, Pretty a, Pretty a) =>
    (a, [a], Maybe (a, [a])) -> Doc ann
    ppInput [WithAccInput rep]
    inputs) Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Lambda rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Lambda rep -> Doc ann
    pretty Lambda rep
    lam)
        where
          ppInput :: (a, [a], Maybe (a, [a])) -> Doc ann
    ppInput (a
    shape, [a]
    arrs, Maybe (a, [a])
    op) =
            Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens
              ( a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    shape
                  Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma
                    Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ((a -> Doc ann) -> [a] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [a]
    arrs)
                  Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> case Maybe (a, [a])
    op of
                    Maybe (a, [a])
    Nothing -> Doc ann
    forall a. Monoid a => a
    mempty
                    Just (a
    op', [a]
    nes) ->
                      Doc ann
    forall ann. Doc ann
    comma Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens (a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    op' Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTuple' ((a -> Doc ann) -> [a] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [a]
    nes))
              )

    instance (PrettyRep rep) => Pretty (Lambda rep) where
      pretty :: forall ann. Lambda rep -> Doc ann
    pretty (Lambda [] [] (Body BodyDec rep
    _ Stms rep
    stms [])) | Stms rep
    stms Stms rep -> Stms rep -> Bool
    forall a. Eq a => a -> a -> Bool
    == Stms rep
    forall a. Monoid a => a
    mempty = Doc ann
    "nilFn"
      pretty (Lambda [Param (LParamInfo rep)]
    params [Type]
    rettype Body rep
    body) =
        Doc ann
    "\\"
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    braces ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commastack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Param (LParamInfo rep) -> Doc ann)
    -> [Param (LParamInfo rep)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Param (LParamInfo rep) -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Param (LParamInfo rep) -> Doc ann
    pretty [Param (LParamInfo rep)]
    params)
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Int -> Doc ann -> Doc ann
    forall ann. Int -> Doc ann -> Doc ann
    indent Int
    2 (Doc ann
    forall ann. Doc ann
    colon Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTupleLines' ((Type -> Doc ann) -> [Type] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Type -> Doc ann
    pretty [Type]
    rettype) Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "->")
          Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Int -> Doc ann -> Doc ann
    forall ann. Int -> Doc ann -> Doc ann
    indent Int
    2 (Body rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Body rep -> Doc ann
    pretty Body rep
    body)

    instance Pretty Signedness where
      pretty :: forall ann. Signedness -> Doc ann
    pretty Signedness
    Signed = Doc ann
    "signed"
      pretty Signedness
    Unsigned = Doc ann
    "unsigned"

    instance Pretty ValueType where
      pretty :: forall ann. ValueType -> Doc ann
    pretty (ValueType Signedness
    s (Rank Int
    r) PrimType
    t) =
        [Doc ann] -> Doc ann
    forall a. Monoid a => [a] -> a
    mconcat (Int -> Doc ann -> [Doc ann]
    forall a. Int -> a -> [a]
    replicate Int
    r Doc ann
    "[]") Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Text -> Doc ann
    forall ann. Text -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Bool -> PrimType -> Text
    prettySigned (Signedness
    s Signedness -> Signedness -> Bool
    forall a. Eq a => a -> a -> Bool
    == Signedness
    Unsigned) PrimType
    t)

    instance Pretty EntryPointType where
      pretty :: forall ann. EntryPointType -> Doc ann
    pretty (TypeTransparent ValueType
    t) = ValueType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ValueType -> Doc ann
    pretty ValueType
    t
      pretty (TypeOpaque Name
    desc) = Doc ann
    "opaque" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    dquotes (Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    desc)

    instance Pretty EntryParam where
      pretty :: forall ann. EntryParam -> Doc ann
    pretty (EntryParam Name
    name Uniqueness
    u EntryPointType
    t) = Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    name Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    colon Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Uniqueness -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Uniqueness -> Doc ann
    pretty Uniqueness
    u Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> EntryPointType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. EntryPointType -> Doc ann
    pretty EntryPointType
    t

    instance Pretty EntryResult where
      pretty :: forall ann. EntryResult -> Doc ann
    pretty (EntryResult Uniqueness
    u EntryPointType
    t) = Uniqueness -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Uniqueness -> Doc ann
    pretty Uniqueness
    u Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> EntryPointType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. EntryPointType -> Doc ann
    pretty EntryPointType
    t

    instance (PrettyRep rep) => Pretty (FunDef rep) where
      pretty :: forall ann. FunDef rep -> Doc ann
    pretty (FunDef Maybe EntryPoint
    entry Attrs
    attrs Name
    name [(RetType rep, RetAls)]
    rettype [Param (FParamInfo rep)]
    fparams Body rep
    body) =
        [Doc ann] -> Doc ann -> Doc ann
    forall a. [Doc a] -> Doc a -> Doc a
    annot (Attrs -> [Doc ann]
    forall a. Attrs -> [Doc a]
    attrAnnots Attrs
    attrs) (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall a b. (a -> b) -> a -> b
    $
          Doc ann
    forall ann. Doc ann
    fun
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Int -> Doc ann -> Doc ann
    forall ann. Int -> Doc ann -> Doc ann
    indent Int
    2 (String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (Name -> String
    nameToString Name
    name))
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    commastack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (Param (FParamInfo rep) -> Doc ann)
    -> [Param (FParamInfo rep)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map Param (FParamInfo rep) -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Param (FParamInfo rep) -> Doc ann
    pretty [Param (FParamInfo rep)]
    fparams)
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> Int -> Doc ann -> Doc ann
    forall ann. Int -> Doc ann -> Doc ann
    indent Int
    2 (Doc ann
    forall ann. Doc ann
    colon Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTupleLines' ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ ((RetType rep, RetAls) -> Doc ann)
    -> [(RetType rep, RetAls)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (RetType rep, RetAls) -> Doc ann
    forall t a. Pretty t => (t, RetAls) -> Doc a
    prettyRet [(RetType rep, RetAls)]
    rettype))
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    equals
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" (Body rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Body rep -> Doc ann
    pretty Body rep
    body)
        where
          fun :: Doc ann
    fun = case Maybe EntryPoint
    entry of
            Maybe EntryPoint
    Nothing -> Doc ann
    "fun"
            Just (Name
    p_name, [EntryParam]
    p_entry, [EntryResult]
    ret_entry) ->
              Doc ann
    "entry"
                Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> (Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    parens (Doc ann -> Doc ann) -> (Doc ann -> Doc ann) -> Doc ann -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    align)
                  ( Doc ann
    "\""
                      Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    p_name
                      Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "\""
                      Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma
                        Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTupleLines' ((EntryParam -> Doc ann) -> [EntryParam] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map EntryParam -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. EntryParam -> Doc ann
    pretty [EntryParam]
    p_entry)
                      Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    forall ann. Doc ann
    comma
                        Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    </> [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    ppTupleLines' ((EntryResult -> Doc ann) -> [EntryResult] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map EntryResult -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. EntryResult -> Doc ann
    pretty [EntryResult]
    ret_entry)
                  )

    instance Pretty OpaqueType where
      pretty :: forall ann. OpaqueType -> Doc ann
    pretty (OpaqueType [ValueType]
    ts) =
        Doc ann
    "opaque" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (ValueType -> Doc ann) -> [ValueType] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map ValueType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ValueType -> Doc ann
    pretty [ValueType]
    ts)
      pretty (OpaqueRecord [(Name, EntryPointType)]
    fs) =
        Doc ann
    "record" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ ((Name, EntryPointType) -> Doc ann)
    -> [(Name, EntryPointType)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Name, EntryPointType) -> Doc ann
    forall {a} {a} {ann}. (Pretty a, Pretty a) => (a, a) -> Doc ann
    p [(Name, EntryPointType)]
    fs)
        where
          p :: (a, a) -> Doc ann
    p (a
    f, a
    et) = a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    f Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    ":" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    et
      pretty (OpaqueSum [ValueType]
    ts [(Name, [(EntryPointType, [Int])])]
    cs) =
        Doc ann
    "sum" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ [ValueType] -> Doc ann
    forall ann. [ValueType] -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [ValueType]
    ts Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : ((Name, [(EntryPointType, [Int])]) -> Doc ann)
    -> [(Name, [(EntryPointType, [Int])])] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Name, [(EntryPointType, [Int])]) -> Doc ann
    forall {a} {a} {ann}. (Pretty a, Pretty a) => (a, [a]) -> Doc ann
    p [(Name, [(EntryPointType, [Int])])]
    cs)
        where
          p :: (a, [a]) -> Doc ann
    p (a
    c, [a]
    ets) = [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    hsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Doc ann
    "#" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    c Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : (a -> Doc ann) -> [a] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [a]
    ets
      pretty (OpaqueArray Int
    r Name
    v [ValueType]
    ts) =
        Doc ann
    "array" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Int -> Doc ann
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Int
    r
          Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "d"
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    dquotes (Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    v)
            Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ (ValueType -> Doc ann) -> [ValueType] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map ValueType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ValueType -> Doc ann
    pretty [ValueType]
    ts)
      pretty (OpaqueRecordArray Int
    r Name
    v [(Name, EntryPointType)]
    fs) =
        Doc ann
    "record_array" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Int -> Doc ann
    forall ann. Int -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Int
    r Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    "d" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    dquotes (Name -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. Name -> Doc ann
    pretty Name
    v) Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ ((Name, EntryPointType) -> Doc ann)
    -> [(Name, EntryPointType)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Name, EntryPointType) -> Doc ann
    forall {a} {a} {ann}. (Pretty a, Pretty a) => (a, a) -> Doc ann
    p [(Name, EntryPointType)]
    fs)
        where
          p :: (a, a) -> Doc ann
    p (a
    f, a
    et) = a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    f Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Doc ann
    ":" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    et

    instance Pretty OpaqueTypes where
      pretty :: forall ann. OpaqueTypes -> Doc ann
    pretty (OpaqueTypes [(Name, OpaqueType)]
    ts) = Doc ann
    "types" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann -> Doc ann -> Doc ann
    forall a. Doc a -> Doc a -> Doc a -> Doc a
    nestedBlock Doc ann
    "{" Doc ann
    "}" ([Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ ((Name, OpaqueType) -> Doc ann)
    -> [(Name, OpaqueType)] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map (Name, OpaqueType) -> Doc ann
    forall {a} {a} {ann}. (Pretty a, Pretty a) => (a, a) -> Doc ann
    p [(Name, OpaqueType)]
    ts)
        where
          p :: (a, a) -> Doc ann
    p (a
    name, a
    t) = Doc ann
    "type" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann
    dquotes (a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    name) Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    forall ann. Doc ann
    equals Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> a -> Doc ann
    forall ann. a -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty a
    t

    instance (PrettyRep rep) => Pretty (Prog rep) where
      pretty :: forall ann. Prog rep -> Doc ann
    pretty (Prog OpaqueTypes
    types Stms rep
    consts [FunDef rep]
    funs) =
        [Doc ann] -> Doc ann
    forall a. [Doc a] -> Doc a
    stack ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
    forall a b. (a -> b) -> a -> b
    $ Doc ann -> [Doc ann] -> [Doc ann]
    forall ann. Doc ann -> [Doc ann] -> [Doc ann]
    punctuate Doc ann
    forall ann. Doc ann
    line ([Doc ann] -> [Doc ann]) -> [Doc ann] -> [Doc ann]
    forall a b. (a -> b) -> a -> b
    $ OpaqueTypes -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. OpaqueTypes -> Doc ann
    pretty OpaqueTypes
    types Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : Stms rep -> Doc ann
    forall ann. Stms rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Stms rep
    consts Doc ann -> [Doc ann] -> [Doc ann]
    forall a. a -> [a] -> [a]
    : (FunDef rep -> Doc ann) -> [FunDef rep] -> [Doc ann]
    forall a b. (a -> b) -> [a] -> [b]
    map FunDef rep -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. FunDef rep -> Doc ann
    pretty [FunDef rep]
    funs

    instance (Pretty d) => Pretty (DimIndex d) where
      pretty :: forall ann. DimIndex d -> Doc ann
    pretty (DimFix d
    i) = d -> Doc ann
    forall ann. d -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty d
    i
      pretty (DimSlice d
    i d
    n d
    s) = d -> Doc ann
    forall ann. d -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty d
    i Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    ":+" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> d -> Doc ann
    forall ann. d -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty d
    n Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Doc ann
    "*" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> d -> Doc ann
    forall ann. d -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty d
    s