aihc-parser-0.1.0.0: From-scratch Haskell parser with differential tests
Safe HaskellNone
LanguageGHC2021

Aihc.Parser.Shorthand

Description

This module provides a compact, human-readable representation of parsed AST structures via the Shorthand typeclass. Key features:

  • Source spans are omitted to reduce noise
  • Empty fields (Nothing, [], False, etc.) are omitted
  • Output is on a single line by default
  • Uses the prettyprinter library for consistent formatting

Example:

>>> shorthand $ parseModule defaultConfig "module Demo where x = 1"
ParseOk (Module {name = "Demo", decls = [DeclValue (FunctionBind "x" [Match {rhs = UnguardedRhs (EInt 1)}])]})
Synopsis

Documentation

class Shorthand a where Source #

Typeclass for compact, human-readable AST representations.

The shorthand method produces a Doc that can be rendered to text or shown as a string. This is useful for debugging and golden tests.

Use show on the result of shorthand to get a String:

show (shorthand expr) :: String

Methods

shorthand :: a -> Doc () Source #

Instances

Instances details
Shorthand LexToken Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Methods

shorthand :: LexToken -> Doc () Source #

Shorthand LexTokenKind Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Shorthand Expr Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Methods

shorthand :: Expr -> Doc () Source #

Shorthand Module Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Methods

shorthand :: Module -> Doc () Source #

Shorthand Pattern Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Methods

shorthand :: Pattern -> Doc () Source #

Shorthand Type Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Methods

shorthand :: Type -> Doc () Source #

Shorthand a => Shorthand (ParseResult a) Source # 
Instance details

Defined in Aihc.Parser.Shorthand

Methods

shorthand :: ParseResult a -> Doc () Source #