25.10.2015 Views

Write You a Haskell Stephen Diehl

1kEcQTb

1kEcQTb

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

So for instance if we have three AST monadic transformations (a, b, c) that we wish to compose into a<br />

single pass t we can use composeM to to generate the composite transformation.<br />

a :: Expr -> RewriteM Expr<br />

b :: Expr -> RewriteM Expr<br />

c :: Expr -> RewriteM Expr<br />

t :: Expr -> RewriteM Expr<br />

t = a ‘composeM‘ b ‘composeM‘ c<br />

Later we utilize both GHC.Generics and Uniplate to generalize this technique even more.<br />

Full Source<br />

e partial source for the Frontend of Proto<strong>Haskell</strong> is given. is is a stub of the all the data structure<br />

and scaffolding we will use to construct the compiler pipeline.<br />

• Proto<strong>Haskell</strong> Frontend<br />

e modules given are:<br />

• Monad.hs - Compiler monad<br />

• Flags.hs - Compiler flags<br />

• Frontend.hs - Frontend syntax<br />

• Name.hs - Syntax names<br />

• Compiler.hs - Initial compiler stub<br />

• Pretty.hs - Pretty printer<br />

• Type.hs - Type syntax<br />

Resources<br />

See:<br />

• e Architecture of Open Source Applications: GHC<br />

• GHC Commentary<br />

127

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!