polytropos-plugin
Safe HaskellNone
LanguageGHC2021

Polytropos.Plugin.Source

Description

Source plugin for polytropos.

Desugars ergonomic syntax for row-polymorphic records, open variants, and declaration forms into standard Polytropos runtime combinators before renaming and typechecking:

  1. Record Construction: REC { x = 1, y = True } (bare) and REC_F { x = Just 1 } (HKD) with field punning support.
  2. Variant Injection: VAR { Ok = 200 } or VARIANT { Err = "fail" }.
  3. Record Updates: REC_UPD r { x = 42 } into setField chains.
  4. Pattern Matching: REC { x, y } into record view patterns, and VAR { Tag = pat } into variant projection view patterns.
  5. Open Declarations: data Person = Person { name :: String, age :: Int } deriving OpenRecord and data Status = Active | Inactive String deriving OpenVariant.
Synopsis
  • sourcePlugin :: [CommandLineOption] -> ParsedResult -> Hsc ParsedResult

Documentation

sourcePlugin :: [CommandLineOption] -> ParsedResult -> Hsc ParsedResult Source #

Top-level entry point for GHC's parsedResultAction. Invoked immediately after GHC's parser completes on each source file. See Note [Source Plugin Desugaring Architecture: Syntactic Sugar Before Typechecking] [ref:note-source-plugin-arch]