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.

If the Proto<strong>Haskell</strong> compiler is invoked either in GHCi or as standable executable, you will see a similar<br />

interactive shell.<br />

_ _ _ | Proto<strong>Haskell</strong> Compiler 0.1.0<br />

| | | | __ _ ___| | __ | Copyright (c) 2013-2015 <strong>Stephen</strong> <strong>Diehl</strong><br />

| |_| |/ _‘ / __| |/ / | Released under the MIT License<br />

| _ | (_| \__ \ < |<br />

|_| |_|\__,_|___/_|\_\ | Type :help for help<br />

Compiling module: prelude.fun<br />

> id (1+2)<br />

3<br />

> :type (>>=)<br />

(>>=) :: Monad m => m a -> (a -> m b) -> m b<br />

> :set -ddump-rn<br />

> :load test.fun<br />

Command line conventions will follow the <strong>Haskell</strong>’s naming conventions. ere will be a strong emphasis<br />

on building debugging systems on top of our architecture so that when subtle bugs creep up you will<br />

have the tools to diagnose the internal state of the type system and detect flaws in the implementation.<br />

Command<br />

:browse<br />

:load <br />

:reload<br />

:edit<br />

:core<br />

:module<br />

:source<br />

:type<br />

:kind<br />

:set <br />

:unset <br />

:ekg <br />

:constraints<br />

:quit<br />

Action<br />

Browse the type signatures for a program<br />

Load a program from file<br />

Run the active file<br />

Edit the active file in system editor<br />

Show the core of an expression or program<br />

Show active modules imports<br />

Show the source code of an expression or program<br />

Show the type of an expression<br />

Show the kind of an expression<br />

Set a flag<br />

Unset a flag<br />

Start the EKG profiler as a background process<br />

Dump the typing constraints for an expression<br />

Exit interpreter<br />

e most notable difference is the very important :core command which will dump out the core representation<br />

of any expression given in the interactive shell. Also the :constraints which will interactively<br />

walk you through the type checker’s reasoning about it how derived the type it did for a given expression.<br />

Proto<strong>Haskell</strong>> :type plus<br />

plus :: forall a. Num a => a -> a -> a<br />

109

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

Saved successfully!

Ooh no, something went wrong!