getOpt package:ghc

Retrieve the options corresponding to a particular opt_* field in the correct order
Parse OPTIONS and LANGUAGE pragmas of the source file. Throws a SourceError if flag parsing fails (including unsupported flags.)
Parse OPTIONS and LANGUAGE pragmas of the source file. Throws a SourceError if flag parsing fails (including unsupported flags.)
Parse option pragma in JS file