25.10.2015 Views

Write You a Haskell Stephen Diehl

1kEcQTb

1kEcQTb

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Proto<strong>Haskell</strong>> :core id<br />

id :: forall a. a -> a<br />

id = \(ds1 : a) -> a<br />

Proto<strong>Haskell</strong>> :core compose<br />

compose :: forall c d e. (d -> e) -> (c -> d) -> c -> e<br />

compose = \(ds1 : d -> e)<br />

(ds2 : c -> d)<br />

(ds3 : c) -><br />

(ds1 (ds2 ds3))<br />

e flags we use also resemble GHC’s and allow dumping out the pretty printed form of each of the<br />

intermediate transformation passes.<br />

• -ddump-parsed<br />

• -ddump-desugar<br />

• -ddump-rn<br />

• -ddump-infer<br />

• -ddump-core<br />

• -ddump-types<br />

• -ddump-stg<br />

• -ddump-imp<br />

• -ddump-c<br />

• -ddump-llvm<br />

• -ddump-asm<br />

• -ddump-to-file<br />

e implementation of the interactive shell will use a custom library called repline , which is a higherlevel<br />

wrapper on top of haskeline made to be more pleasant when writing interactive shells.<br />

Parser<br />

We will use the normal Parsec parser with a few extensions. We will add indentation sensitive parser so<br />

that block syntax ( where statements, let statements, do-notation ) can be parsed.<br />

main :: IO ()<br />

main = do<br />

putStrLn msg<br />

where<br />

msg = ”Hello World”<br />

In addition we will need to allow for the addition of infix operators from be user-defined declarations,<br />

and allow this information to be used during parsing.<br />

110

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

Saved successfully!

Ooh no, something went wrong!