plugins-1.5.2.2: Dynamic linking for Haskell and C objects

Safe HaskellSafe-Infered

System.Plugins.Parser

Synopsis

Documentation

parseSource

Arguments

:: FilePath

module name

-> String

haskell src

-> Either String HsModule

abstract syntax

parse a file (as a string) as Haskell src

mergeModules :: HsModule -> HsModule -> HsModuleSource

mergeModules : generate a full Haskell src file, give a .hs config file, and a stub to take default syntax and decls from. Mostly we just ensure they don't do anything bad, and that the names are correct for the module.

Transformations:

. Take src location pragmas from the conf file (1st file) . Use the template's (2nd argument) module name . Only use export list from template (2nd arg) . Merge top-level decls . need to force the type of the plugin to match the stub, overwriting any type they supply.

pretty :: HsModule -> StringSource

pretty print haskell src

doesn't handle operators with '#' at the end. i.e. unsafeCoerce#

parsePragmasSource

Arguments

:: String

input src

-> ([String], [String])

normal options, global options

Parsing option pragmas.

This is not a type checker. If the user supplies bogus options, they'll get slightly mystical error messages. Also, we want to handle -package options, and other static flags. This is more than GHC.

GHC user's guide :

    OPTIONS pragmas are only looked for at the top of your source
    files, up to the first (non-literate,non-empty) line not
    containing OPTIONS. Multiple OPTIONS pragmas are recognised.

based on getOptionsFromSource(), in main/DriverUtil.hs

data HsModule

A Haskell source module.

replaceModName :: HsModule -> String -> HsModuleSource

replace Module name with String.