Skip to content

Commit

Permalink
Improve haddocks for inlining and printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj committed Apr 20, 2024
1 parent b7c0c87 commit 5f13330
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/HordeAd/Core/AstInterpret.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
{-# OPTIONS_GHC -fmax-pmcheck-models=10000 #-}
{-# OPTIONS_GHC -freduction-depth=10000 #-}
-- | Interpretation of AST terms in an aribtrary @RankedTensor@
-- and/or @ShapedTensor@ class instance.
-- | Interpretation of AST terms in an aribtrary @RankedTensor@ & Co instance.
-- With the exception of the the interpretation of the sharing mechanisms,
-- the interpretation is the unique homorphism determined by the instance.
-- The sharing mechanisms are translated so as to preserve sharing in case
-- the instance is a term algebra as well.
module HordeAd.Core.AstInterpret
( interpretAstPrimal, interpretAst
, interpretAstPrimalS, interpretAstS
Expand Down
15 changes: 8 additions & 7 deletions src/HordeAd/Core/AstPrettyPrint.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
{-# OPTIONS_GHC -fconstraint-solver-iterations=10000 #-}
-- | Pretty-printing of AST of the code to be differentiated or resulting
-- from the differentiation.
-- | Pretty-printing of the AST. Some of the variants of pretty-printing
-- almost roundtrip, while others are more readable but less faithful.
module HordeAd.Core.AstPrettyPrint
( -- * Pretty-print variables
( -- * Pretty-printing of variables
printAstVarName, printAstVarNameS, printAstDynamicVarNameBrief
, printAstDynamicVarName
, printAstIntVarName
-- * User-friendly API for pretty-printing AST terms
-- * Pretty-printing terms in a few useful configurations
, printAstSimple, printAstPretty, printAstPrettyButNested
, printAstSimpleS, printAstPrettyS, printAstPrettyButNestedS
, printAstHVectorSimple, printAstHVectorPretty, printAstHVectorPrettyButNested
Expand Down Expand Up @@ -43,7 +43,8 @@ import HordeAd.Util.SizedList

-- TODO: ensure that terms roundtrip if neither loseRoudtrip
-- nor ignoreNestedLambdas is set.
-- Ideally, it would also preserve sharing.
-- Ideally, pretty-printing would also preserve the explicit sharing
-- in this case instead of displaying it as Haskell sharing.
-- Note that other options may cause the roundtrip to cost more than
-- a single pass over the term, e.g., ignoreNestedLambdas causes derivatives
-- to be recomputed.
Expand Down Expand Up @@ -113,7 +114,7 @@ areAllArgsInts = \case
AstD{} -> False -- dual number


-- * Pretty-print variables
-- * Pretty-printing of variables

printAstVarId :: String -> PrintConfig -> AstVarId -> ShowS
printAstVarId prefix cfg var =
Expand Down Expand Up @@ -936,7 +937,7 @@ printAstRelOp pr cfg d opCode u v = case opCode of
GtOp -> printBinaryOp pr cfg d u (4, " >. ") v


-- * User-friendly API for pretty-printing AST terms
-- * Pretty-printing terms in a few useful configurations

printAstSimple :: (GoodScalar r, KnownNat n, AstSpan s)
=> IntMap String -> AstRanked s r n -> String
Expand Down

0 comments on commit 5f13330

Please sign in to comment.