Yhc/API/Core
From HaskellWiki
(Difference between revisions)
(→Generating Core) |
(→Blog Posts) |
||
| Line 2: | Line 2: | ||
Yhc Core is a way of dumping and using the internal representation of Yhc in an external project. The code related to this, including data types, is found in src/compiler/Core directory of the Yhc source code. | Yhc Core is a way of dumping and using the internal representation of Yhc in an external project. The code related to this, including data types, is found in src/compiler/Core directory of the Yhc source code. | ||
| + | |||
| + | == Haddock Documentation == | ||
| + | |||
| + | * http://www.cs.york.ac.uk/fp/yhc/snapshot/docs/Yhc-Core.html | ||
== Blog Posts == | == Blog Posts == | ||
Revision as of 07:24, 11 October 2006
| Part of Yhc |
Yhc Core is a way of dumping and using the internal representation of Yhc in an external project. The code related to this, including data types, is found in src/compiler/Core directory of the Yhc source code.
Contents |
1 Haddock Documentation
2 Blog Posts
The following sequence of blog posts probably gives a useful introduction to Yhc Core.
- http://yhc06.blogspot.com/2005/12/yhc-core.html
- http://yhc06.blogspot.com/2006/07/yhc-core-v2.html
- http://yhc06.blogspot.com/2006/09/yhccore-api-available.html
3 Generating Core
To generate Core, simply give the compiler the option -core or -corep. For example, when compiling
module FibMain where
main xs = pam daeh xs
daeh (x:xs) = x
pam f [] = [] pam f (x:xs) = f x : pam f xs
You get the output
$ yhc -core FibMain.hs
====== Human Readable Core:
FibMain.pam v220 v221 =
case v221 of
Prelude.[] -> (Prelude.[])
Prelude.: v222 v223 ->
(Prelude.: (YHC.Internal._apply1 v220 v222) (FibMain.pam v220 v223))
FibMain.daeh v224 =
case v224 of
Prelude.: v225 v226 -> v225
_ -> (Prelude.error (LAMBDA228))
LAMBDA228 =
(prim_STRING "FibMain: Pattern match failure in function at 7:1-7:15.")
FibMain.main v227 = (FibMain.pam FibMain.daeh v227)
The -core option gives human readable Core output, in a style very similar to Haskell. The -corep option gives a deriving Show output of the Core, which can be read back in with read very easily. The machine Core also contains source code locations for statements.
4 Compared to GHC Core
- Types - Yhc has none, GHC has lots.
- Familiarity - Yhc looks like Haskell, GHC is somewhat related, but not as close.
- Name mangling - Yhc preserves names much better.
- Source locations - Yhc keeps these, GHC doesn't.
5 Users
- Catch - Case and Termination Checker for Haskell by Neil Mitchell. This takes Core as an input.
- Dr Haskell - give hints to beginners about useful Haskell functions/idioms.
