Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Pretty printing of function representations.
Warning
This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time. It is made available only for debugging. Otherwise, use Test.Fun.
If something here seems useful, please open an issue to export it from an external module.
Synopsis
- showsPrecFun :: forall a r. ShowsPrec r -> ShowsPrec (a :-> r)
- indent :: String -> String
- prettyFun :: forall a r. (r -> C Expr) -> (a :-> r) -> String
- type DString = String -> String
- type PrecDString = Int -> DString
- sid :: DString
- sstring :: String -> DString
- (%) :: DString -> DString -> DString
- (~%) :: String -> DString -> DString
- sparens :: Int -> DString -> PrecDString
- newtype Expr = Expr {}
- type Pattern = Expr
- unExpr_ :: Expr -> DString
- data Var = Var String !Int
- data Ctx = (Var, Expr) :. Ctx
- defVar :: Var
- defCtx :: Ctx
- badCtx :: Ctx
- type C a = Ctx -> a
- eWild :: Pattern
- eConst :: String -> Expr
- tConst :: String -> C Expr
- eInt :: Integer -> Expr
- eApp :: Expr -> Expr -> Expr
- tShow :: Show a => a -> C Expr
- tShow_ :: ShowsPrec a -> a -> C Expr
- sVar :: Var -> DString
- eVar :: Var -> Expr
- addVar :: [Var] -> Ctx -> Ctx
- tFun :: forall a r. (r -> C Expr) -> (a :-> r) -> C Expr
- tApply :: FunName -> C Expr -> C Expr
- tCoApply :: Concrete w -> w -> C Expr -> C Expr
- tAbsurd :: C Expr
- appendIf :: Semigroup m => Bool -> m -> m -> m
- partialBranches :: Branches x r -> Bool
- type CBranches = Var -> C [EBranch]
- data EBranch
- bEllipsis :: Bin r -> CBranches
- bWild :: C Expr -> CBranches
- tCase :: TypeName -> CBranches -> C Expr
- tBranches :: forall x r. (r -> C Expr) -> Branches x r -> CBranches
- tFields :: forall x r. (r -> C Expr) -> Fields x r -> ConName -> [Var] -> CBranches
- nextVar :: Var -> Var
- mkPattern :: ConName -> [Var] -> Pattern
- tBin :: (r -> C Expr) -> Bin r -> CBranches
- data Sign
- resign :: Sign -> Integer -> Integer
- tBin' :: (r -> C Expr) -> Bin r -> C [(Integer, Expr)]
- ellidedBin :: Bin r -> Bool
Interface
showsPrecFun :: forall a r. ShowsPrec r -> ShowsPrec (a :-> r) Source #
Prettify function representation.
indent :: String -> String Source #
Break up lines after braces and indent.
Example
Input:
\x -> case x :: Either _ _ of { Left x1 -> case x1 of { Left x2 -> () ; Right x2 -> case x2 of {} } ; Right x1 -> () }
Output:
\x -> case x :: Either _ _ of { Left x1 -> case x1 of { Left x2 -> () ; Right x2 -> case x2 of {} } ; Right x1 -> () }
Implementation
Strings
type PrecDString = Int -> DString Source #
Pretty-printed expressions
Basic expression constructors
Main implementation
tFun :: forall a r. (r -> C Expr) -> (a :-> r) -> C Expr Source #
Pretty-print a function representation.
partialBranches :: Branches x r -> Bool Source #
True
if there is a Fail
branch.
ellidedBin :: Bin r -> Bool Source #