https://wiki.haskell.org/api.php?action=feedcontributions&user=Jbapple&feedformat=atomHaskellWiki - User contributions [en]2024-03-29T10:04:10ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Haddock&diff=22522Haddock2008-08-19T08:36:07Z<p>Jbapple: main page still shows 2.0, which is broken with GHC 6.8.3</p>
<hr />
<div>[http://haskell.org/haddock/ Haddock] is a tool for automatically generating documentation from annotated Haskell source code. Its main web page is not updated as often as its [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haddock hackage page], so check there for the latest version.<br />
<br />
Haddock is now the de facto standard Haskell documentation tool. It is used for the standard libraries that come with [[GHC]] and [[Hugs]]. It is also supported by [[Cabal]].<br />
<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haddock The hackage page] is updated more often than the main [http://haskell.org/haddock/ Haddock web page]<br />
* [[/Development ideas|Ideas for improving Haddock in various ways.]]<br />
* [[/FAQ|Frequently asked questions about Haddock.]]<br />
* [http://trac.haskell.org/haddock/ Haddock Trac]<br />
<br />
[[Category:Tools]]</div>Jbapplehttps://wiki.haskell.org/index.php?title=Haddock&diff=22521Haddock2008-08-19T08:32:47Z<p>Jbapple: works now</p>
<hr />
<div>[http://haskell.org/haddock/ Haddock] is a tool for automatically generating documentation from annotated Haskell source code.<br />
<br />
Haddock is now the de facto standard Haskell documentation tool. It is used for the standard libraries that come with [[GHC]] and [[Hugs]]. It is also supported by [[Cabal]].<br />
<br />
* The main [http://haskell.org/haddock/ Haddock web page]<br />
* [[/Development ideas|Ideas for improving Haddock in various ways.]]<br />
* [[/FAQ|Frequently asked questions about Haddock.]]<br />
* [http://trac.haskell.org/haddock/ Haddock Trac]<br />
<br />
[[Category:Tools]]</div>Jbapplehttps://wiki.haskell.org/index.php?title=Haddock&diff=21869Haddock2008-07-20T06:08:49Z<p>Jbapple: [http://trac.haskell.org/haddock/ticket/18 Haddock does not presently work with GHC 6.8.3]</p>
<hr />
<div>[http://haskell.org/haddock/ Haddock] is a tool for automatically generating documentation from annotated Haskell source code.<br />
<br />
Haddock is now the de facto standard Haskell documentation tool. It is used for the standard libraries that come with [[GHC]] and [[Hugs]]. It is also supported by [[Cabal]].<br />
<br />
[http://trac.haskell.org/haddock/ticket/18 Haddock does not presently work with GHC 6.8.3]<br />
<br />
* The main [http://haskell.org/haddock/ Haddock web page]<br />
* [[/Development ideas|Ideas for improving Haddock in various ways.]]<br />
* [[/FAQ|Frequently asked questions about Haddock.]]<br />
* [http://trac.haskell.org/haddock/ Haddock Trac]<br />
<br />
[[Category:Tools]]</div>Jbapplehttps://wiki.haskell.org/index.php?title=Haddock&diff=21868Haddock2008-07-20T05:59:01Z<p>Jbapple: * [http://trac.haskell.org/haddock/ Haddock Trac]</p>
<hr />
<div>[http://haskell.org/haddock/ Haddock] is a tool for automatically generating documentation from annotated Haskell source code.<br />
<br />
Haddock is now the de facto standard Haskell documentation tool. It is used for the standard libraries that come with [[GHC]] and [[Hugs]]. It is also supported by [[Cabal]].<br />
<br />
* The main [http://haskell.org/haddock/ Haddock web page]<br />
* [[/Development ideas|Ideas for improving Haddock in various ways.]]<br />
* [[/FAQ|Frequently asked questions about Haddock.]]<br />
* [http://trac.haskell.org/haddock/ Haddock Trac]<br />
<br />
[[Category:Tools]]</div>Jbapplehttps://wiki.haskell.org/index.php?title=GHC/As_a_library_(up_to_6.8)&diff=21867GHC/As a library (up to 6.8)2008-07-20T05:56:03Z<p>Jbapple: Links are broken</p>
<hr />
<div>[[Category:GHC]]<br />
<p style='font-size: xx-large; font-weight:bold; text-align: center'>Using GHC as a library</p><br />
__TOC__<br />
In GHC 6.5 and subsequently you can import GHC as a Haskell library, which lets you write a Haskell program that has access to all of GHC. <br />
<br />
This page is a place for everyone to add<br />
* Notes about how to get it working<br />
* Comments about the API<br />
* Suggestions for improvement<br />
and so on.<br />
<br />
More documentation is available on the GHC wiki: http://cvs.haskell.org/trac/ghc/wiki/Commentary/Compiler/API<br />
<br />
== Getting started ==<br />
You'll need a version of GHC (at least 6.5) that supports the GHC API. The [http://www.haskell.org/ghc/download.html GHC download page] offers stable releases and development versions; you can also use CVS ([http://www.haskell.org/ghc/docs/latest/html/building/sec-cvs.html instructions]) or darcs (e.g., <tt>darcs get --partial http://darcs.haskell.org/ghc</tt>).<br />
<br />
To use the GHC API you say <br />
<haskell><br />
import GHC<br />
</haskell><br />
Doing this imports the module <tt>GHC</tt> from the package <tt>ghc</tt>. This module exports the "GHC API", which is still in a state of flux. Currently it's not even Haddock-documented. You can see the [http://darcs.haskell.org/ghc/compiler/main/GHC.hs source code] (somewhat documented). There are also other modules of interest as you do more special things.<br />
<br />
Here's an example main program that does it [[Media:Main.hs]] (good for GHC 6.6). You need to manually change the value of <tt>myGhcRoot</tt> to point to your GHC directory.<br />
<br />
To compile [[Media:Main.hs]], you have to turn on the flag "-package ghc", e.g.<br />
<pre><br />
ghc -package ghc Main.hs<br />
</pre><br />
<br />
== Common use cases and functions ==<br />
<br />
'''Assumes GHC 6.6.'''<br />
<br />
=== Default exception handling ===<br />
<br />
If you don't handle exceptions yourself, you are recommended to wrap all code inside the wrapper:<br />
<haskell><br />
defaultErrorHandler :: DynFlags -> IO a -> IO a<br />
DynFlags.defaultDynFlags :: DynFlags<br />
</haskell><br />
This catches exceptions and prints out exception details and exits your program with exit code 1.<br />
<br />
Example:<br />
<haskell><br />
import GHC<br />
import DynFlags(defaultDynFlags)<br />
<br />
main = defaultErrorHandler defaultDynFlags $ do<br />
{-<br />
stuff in the following subsections<br />
-}<br />
</haskell><br />
<br />
You do not have to use <hask>defaultDynFlags</hask>, but it's the easiest starting point.<br />
<br />
=== Initialization ===<br />
<br />
First create a session: <br />
<haskell><br />
newSession :: GhcMode -- BatchCompile | Interactive | MkDepend | ...<br />
-> Maybe FilePath -- GHC installation directory<br />
-> IO Session -- your session; you will need it<br />
</haskell><br />
The path to your GHC installation directory (e.g., /usr/local/lib/ghc-6.6) is in practice mandatory, even though in theory marked as optional. Also, in 6.8, the type signature of newSession changed to remove the GhcMode (but retaining the still not actually optional Maybe FilePath:<br />
<br />
<haskell>newSession :: Maybe FilePath -> IO Session</haskell><br />
<br />
The session is configurable by dynamic flags (GHC dynamic flags plus session state; think <tt>-O2</tt>, <tt>-fvia-C</tt>, <tt>-fglasgow-exts</tt>, <tt>-package</tt>). This can be done with:<br />
<haskell><br />
getSessionDynFlags :: Session -> IO DynFlags<br />
setSessionDynFlags :: Session<br />
-> DynFlags<br />
-> IO [PackageId] -- important iff dynamic-linking<br />
parseDynamicFlags :: DynFlags -- old flags<br />
-> [String] -- e.g., all or part of getArgs<br />
-> IO (DynFlags, [String]) -- new flags, unknown args<br />
</haskell><br />
The <hask>DynFlags</hask> record has a gazillion fields; ask ghci to show all of them. You can change them by hand, or use the parser (which implements the GHC command line format and does the Right Thing). But there are a couple you must note:<br />
<haskell><br />
data DynFlags = DynFlags { ...,<br />
hscTarget :: HscTarget } -- HscC | HscAsm | HscInterpreted | ...<br />
</haskell><br />
This corresponds to <tt>-fvia-C</tt>, <tt>-fasm</tt>, or interpreting. When the session needs to re-compile a module, this field controls how. The default is <hask>HscAsm</hask>, ''even in the interactive mode'', meaning the interactive mode may produce .hi and .o files too. If you want to follow GHCi in not doing that, you must set this field to <hask>HscInterpreted</hask> yourself. (On the other hand, it is fun to contemplate an interactive session that generates machine code upon your command.)<br />
<br />
<hask>setSessionDynFlags</hask> also sets up your session's awareness of the package database (without which you can't even use the Prelude), so even if you like the defaults, you should still call it. (Older code called <hask>PackageConfig.initPackages</hask> for this.)<br />
<br />
Examples:<br />
* vanilla compiler, use all defaults (rare but good start)<br />
<haskell><br />
session <- newSession BatchCompile (Just "/usr/local/lib/ghc-6.6")<br />
getSessionDynFlags session >>= setSessionDynFlags session<br />
</haskell><br />
* compiler with custom flags, easy with parser<br />
<haskell><br />
session <- newSession BatchCompile (Just "/usr/local/lib/ghc-6.6")<br />
f0 <- getSessionDynFlags session<br />
(f1,b) <- parseDynamicFlags f0 ["-fglasgow-exts", "-O", "-package", "ghc", "-package Cabal",<br />
"foo", "-v", "bar"]<br />
-- b = ["foo", "bar"]; the other args are recognized<br />
-- in GHC 6.6 "-O" implies "-fvia-C", that kind of thing is automatic here too<br />
setSessionDynFlags session f1<br />
</haskell><br />
* interactive session with interpreter<br />
<haskell><br />
session <- newSession Interactive (Just "/usr/local/lib/ghc-6.6")<br />
f0 <- getSessionDynFlags session<br />
setSessionDynFlags session f0{hscTarget = HscInterpreted}<br />
</haskell><br />
* no linking<br />
The GHC API behaves just like --make: it always links the program if you have a Main module. There are some cases where you will want to turn the linker off; this has the same affect as --make -c. In order to do this, set the ghcLink flag to NoLink:<br />
<haskell><br />
session <- newSession BatchCompile (Just "/usr/local/lib/ghc-6.6")<br />
f0 <- getSessionDynFlags session<br />
(f1,b) <- parseDynamicFlags f0 ["-fglasgow-exts", "-O", "-package", "ghc", "-package Cabal",<br />
"foo", "-v", "bar"]<br />
-- b = ["foo", "bar"]; the other args are recognized<br />
-- in GHC 6.6 "-O" implies "-fvia-C", that kind of thing is automatic here too<br />
setSessionDynFlags session $ f1 {ghcLink=NoLink}<br />
</haskell><br />
=== Load or compile modules ===<br />
<br />
To compile code or load modules, first set one or more targets, then call the <hask>load</hask> function.<br />
<haskell><br />
guessTarget :: String -- "filename.hs" or "filename.lhs" or "MyModule"<br />
-> Maybe Phase -- if not Nothing, specifies starting phase<br />
-> IO Target<br />
addTarget :: Session -> Target -> IO ()<br />
setTargets :: Session -> [Target] -> IO ()<br />
getTargets :: Session -> IO [Target]<br />
removeTarget :: Session -> TargetId -> IO ()<br />
load :: Session -> LoadHowMuch -> IO SuccessFlag<br />
data LoadHowMuch<br />
= LoadAllTargets<br />
| LoadUpTo ModuleName<br />
| LoadDependenciesOf ModuleName<br />
</haskell><br />
<br />
Loading or compiling produces temp directories and files, which can only be correctly cleaned up or kept (depending on temp file flags in <hask>DynFlags</hask>) with the wrapper:<br />
<haskell><br />
defaultCleanupHandler :: DynFlags -> IO a -> IO a<br />
</haskell><br />
Two factors constrain how much code should be wrapped. At the minimal, function calls such as <hask>load</hask> and <hask>depanal</hask> that potentially unlit or compile or link should be wrapped. At the maximal, the flags passed to <hask>defaultCleanupHandler</hask> should be identical to those set to the session, so practically the wrapping should be after setting up seesion flags.<br />
<br />
Example:<br />
<haskell><br />
t <- guessTarget "Main.hs" Nothing<br />
addTarget session t -- setTargets session [t] is also good<br />
f <- getSessionDynFlags session<br />
sf <- defaultCleanupHandler f (load session LoadAllTargets)<br />
case sf of Succeeded -> ...<br />
Failed -> ...<br />
</haskell><br />
<br />
Dependencies (both modules and packages) are processed automatically, and an executable is produced if appropriate, precisely like <tt>--make</tt>.<br />
<br />
Modules are compiled as per the <hask>hscTarget</hask> flag (<tt>-fasm</tt>, <tt>-fvia-C</tt>, or interpreter) in <hask>DynFlags</hask>, ''independent of GHC mode''.<br />
<br />
=== Compiling to and from Core ===<br />
<br />
Note: the following will only work as advertised in the HEAD (GHC 6.9). <br />
<br />
To compile a file to Core (the intermediate language used in GHC's simplifier), call <tt>compileToCoreModule</tt>:<br />
<haskell><br />
compileToCoreModule :: Session -> FilePath -> IO (Maybe CoreModule)<br />
</haskell> <br />
<tt>compileToCoreModule</tt> takes a session and a filename and, if successful, returns a <tt>CoreModule</tt> corresponding to the Haskell module denoted by the filename. It is not necessary to set a target first. <br />
<br />
The <tt>CoreModule</tt> data type is specified in [http://darcs.haskell.org/ghc/compiler/main/HscTypes.lhs the HscTypes module] in GHC. The most important field is probably <tt>cm_binds</tt>, a list of Core bindings for all top-level declarations from the original Haskell source file.<br />
<haskell><br />
data CoreModule<br />
= CoreModule {<br />
-- Module name<br />
cm_module :: !Module,<br />
-- Type environment for types declared in this module<br />
cm_types :: !TypeEnv,<br />
-- Declarations<br />
cm_binds :: [CoreBind]<br />
-- Imports<br />
cm_imports :: ![Module]<br />
}<br />
</haskell><br />
The type <tt>TypeEnv</tt> is defined in [http://darcs.haskell.org/ghc/compiler/main/HscTypes.lhs HscTypes.lhs].<br />
<br />
For documentation of the Core data types, see [http://darcs.haskell.org/ghc/compiler/coreSyn/CoreSyn.lhs the CoreSyn module] in GHC.<br />
<br />
For some applications, you may want to compile the Haskell source for various standard libraries into Core. Given the current API, this is probably only possible in the presence of a GHC tree that was built from source, including libraries. (Otherwise, there may be problems finding the right import files.) If you have experience suggesting otherwise, you may wish to report back.<br />
<br />
You can also compile Core code to object code:<br />
<haskell><br />
compileCoreToObj :: Bool -> Session -> CoreModule -> IO Bool<br />
</haskell> <br />
<tt>compileCoreToObj</tt> takes a boolean flag that says whether or not to run the simplifier, a session, and a <tt>CoreModule</tt>, and returns True iff compilation to machine code succeeded. As a side effect, it creates the executable file, as well as any necessary <tt>.hi</tt> or <tt>.o</tt> files, in the current working directory. This has only been tested with a single self-contained Core module (i.e., one that only depends on standard library functions rather than on functions in other user-defined modules). <br />
<br />
These functions are a work-in-progress, so if you notice anything that is not what you expect, please complain on the cvs-ghc mailing list or [http://hackage.haskell.org/trac/ghc/newticket?type=bug file a bug report].<br />
<br />
=== Interactive evaluation ===<br />
<br />
Interactive evaluation ala GHCi is done by <hask>runStmt</hask>. But first, this is always done under a current context, i.e., which modules are in scope. Most probably you want to have at least the Prelude and those you loaded in the previous section. How to manipulate the context:<br />
<haskell><br />
setContext :: Session<br />
-> [Module] -- their top levels will be visible<br />
-> [Module] -- their exports will be visible<br />
-> IO ()<br />
getContext :: Session -> IO ([Module], [Module])<br />
findModule :: Session -> ModuleName -> Maybe PackageId -> IO Module<br />
mkModule :: PackageId -> ModuleName -> Module<br />
mkModuleName :: String -> ModuleName<br />
PackageConfig.stringToPackageId :: String -> PackageId<br />
</haskell><br />
Every module given to <hask>setContext</hask> must be either in a package known to the session or has been loaded as per the previous subsection. Example:<br />
<haskell><br />
-- equivalent to GHCi's :m Prelude Control.Monad *Main<br />
prelude <- findModule session (mkModuleName "Prelude") Nothing<br />
monad <- findModule session (mkModuleName "Control.Monad") Nothing<br />
usermod <- findModule session (mkModuleName "Main") Nothing -- we have loaded this<br />
setContext session [usermod] [prelude,monad]<br />
</haskell><br />
You can also be specific about packages. You can also use <hask>mkModule</hask> instead of <hask>findModule</hask>, or even some module query functions in the next subsection.<br />
<br />
Having set a useful context, we're now ready to evaluate.<br />
<haskell><br />
runStmt :: Session -> String -> IO RunResult<br />
data RunResult<br />
= RunOk [Name] -- names bound by the expression<br />
| RunFailed<br />
| RunException GHC.IOBase.Exception -- that's Control.Exception.Exception<br />
</haskell><br />
Example:<br />
<haskell><br />
runStmt session "let n = 2 + 2" -- n is bound<br />
runStmt session "n" -- 4 is printed (note "it" is bound)<br />
</haskell><br />
<br />
(Interactive evaluation works in BatchCompile mode too! There are still other subtle differences, so this is not recommended.)<br />
<br />
=== Type checking ===<br />
What if I want the type info from a module?<br />
<br />
Once the modules are loaded in the session, they are already type-checked.<br />
The type information of a loaded module are stored in a data-structure called <br />
<hask>ModuleInfo</hask>. To access the type information, we need to apply function <hask>getModuleInfo</hask> to the target module.<br />
<br />
<hask>ModuleInfo</hask> is defined as follows,<br />
<br />
<haskell><br />
data ModuleInfo = ModuleInfo {<br />
minf_type_env :: TypeEnv,<br />
minf_exports :: NameSet, -- ToDo, [AvailInfo] like ModDetails?<br />
minf_rdr_env :: Maybe GlobalRdrEnv, -- Nothing for a compiled/package mod<br />
minf_instances :: [Instance]<br />
#ifdef GHCI<br />
,minf_modBreaks :: ModBreaks <br />
#endif<br />
-- ToDo: this should really contain the ModIface too<br />
}<br />
</haskell><br />
The field <hask>minf_type_env</hask> is holding the type environment, of type <hask>TypeEnv</hask>, which is defined as,<br />
<haskell><br />
type TypeEnv = [TyThing]<br />
</haskell><br />
where TyThing can be an identifier, a class, a type constructor or a data constructor.<br />
<haskell><br />
data TyThing = AnId Id<br />
| ADataCon DataCon<br />
| ATyCon TyCon<br />
| AClass Class<br />
</haskell><br />
<br />
Recalling the running example in the previous subsection, note that the variable <hask>usermod</hask> captures the user-defined module "Main". <br />
We retrieve the module information of "Main" module and unfold the type environment out of it.<br />
<haskell><br />
mb_userModInfo <- getModuleInfo session usermod<br />
case mb_userModInfo of <br />
Just userModInfo -><br />
let userTyThings = modInfoTyThings userModInfo -- access the type environments<br />
userTys = [ (i, idType i) | (AnId i) <- userTyThings ] -- we are only interested in the declared ids and their (inferred) types. <br />
in ... -- do something with userTys<br />
Nothing -> return ()<br />
</haskell><br />
<br />
<br />
=== Queries ===<br />
<br />
<haskell><br />
-- Get module dependency graph<br />
getModuleGraph :: Session -> IO ModuleGraph -- ModuleGraph = [ModSummary]<br />
-- Get bindings<br />
getBindings :: Session -> IO [TyThing]<br />
</haskell><br />
<br />
=== Messages ===<br />
<br />
Compiler messages (including progress, warnings, errors) are controlled by verbosity and routed through a callback mechanism. These are fields in <hask>DynFlags</hask>:<br />
<haskell><br />
data DynFlags = DynFlags { ...,<br />
verbosity :: Int,<br />
log_action :: Severity -> SrcLoc.SrcSpan -> Outputable.PprStyle -> ErrUtils.Message -> IO () }<br />
</haskell><br />
<br />
The <hask>verbosity</hask> field corresponds to the command line <tt>-v</tt> flag; <hask>parseDynamicFlags</hask> is applicable. A low verbosity means <hask>log_action</hask> is seldom called.<br />
<br />
You can set the callback to your logger, like<br />
<haskell><br />
f <- getSessionDynFlags session<br />
setSessionDynFlags session f{log_action = my_log_action}<br />
</haskell><br />
This sets the session's logger, but it will not see exceptions.<br />
<br />
If you call <hask>defaultErrorHandler</hask> at the outermost, clearly its message logger has to be set separately:<br />
<haskell><br />
main = defaultErrorHandler defaultDynFlags{log_action = my_log_action} $ do ...<br />
</haskell><br />
This logger will see messages produced by <hask>defaultErrorHandler</hask> upon exceptions.<br />
<br />
== Interactive mode example ==<br />
<br />
The file [[Media:Interactive-6.6.hs]] or [[Media:Interactive-6.8.hs]] (requires [[Media:MyPrelude.hs]]) serve as an example for using GHC as a library in interactive mode. It also shows how to replace some of the standard prelude functions with modified versions. See the comments in the code for further information.<br />
<br />
== Using the GHC library from inside GHCi ==<br />
<br />
This works, to some extent. However, beware about loading object code, because there is only a single linker symbol table in the runtime, so GHCi will be sharing the symbol table with the new GHC session.<br />
<br />
<pre><br />
$ ghci -package ghc<br />
Prelude> :m + GHC PackageConfig<br />
Prelude GHC> session <- newSession Interactive (Just "/usr/local/lib/ghc-6.6")<br />
Prelude GHC> setSessionDynFlags session =<< getSessionDynFlags session<br />
Prelude GHC> setContext session [] [mkModule (stringToPackageId "base") (mkModuleName "Prelude")]<br />
Prelude GHC> runStmt session "let add1 x = x + 1"<br />
Prelude GHC> runStmt session "add1 2"<br />
3<br />
</pre><br />
<br />
== Profiling ==<br />
<br />
To build the profiling version of GHC-as-a-library, add:<br />
<pre><br />
GhcCompilerWays=p<br />
</pre><br />
to your <tt>build.mk</tt> file, and rebuild GHC.<br />
<br />
<b>Note</b>: This seems to be broken as of [http://hackage.haskell.org/trac/ghc/ticket/2377 GHC 6.8.3].<br />
<br />
== Binary size ==<br />
<br />
Using the GHC API in your<br />
applications results in large executables (e.g. > 15Mb). You can mitigate this by an enormous amount using the tools <tt>strip</tt> and <tt>gzexe</tt>; this may reduce the executable to 15-30% of its previous size. ([http://austin.youareinferior.net/?q=node/29 Example]:<br />
<blockquote>"I will take this time to point out that using the GHC API in your <br />
applications results in *large* executables. The Interact example <br />
above when compiled with vanilla --make options resulted in a whopping <br />
17mb executable. I've observed however you can mitigate this by an <br />
enormous amount using the tools strip and gzexe [see also upx. -ed], taking it down to a light 2.5mb (a size reduction of about 85%)."[http://groups.google.com/group/fa.haskell/browse_thread/thread/90203222e5830d0a]</blockquote> <!-- I also found the page cached as <http://72.14.205.104/search?q=cache:DXz9SkIg0OAJ:austin.youareinferior.net/%3Fq%3Dnode/29+http://austin.youareinferior.net/%3Fq%3Dnode/29&hl=en&ct=clnk&cd=1&gl=us> --><br />
<br />
(Using 6.8.1 for me results in a 16M binary using the example interactive session from this page, even when thoroughly stripped. Using UPX on its most intensive settings brought it down to 2.9M. --[[User:Gwern|Gwern]])</div>Jbapplehttps://wiki.haskell.org/index.php?title=Blog_articles/Mathematics&diff=13929Blog articles/Mathematics2007-07-02T16:13:54Z<p>Jbapple: Expanding titles, adding back in dropped '&omega;'</p>
<hr />
<div>Articles using Haskell for mathematics, and the mathematics of Haskell.<br />
<br />
For further references see the:<br />
<br />
* [[Haskell_and_mathematics|Haskell math community]].<br />
* [[Blog_articles/Monads|Mathematics of monads]]<br />
<br />
== Haskell for mathematics ==<br />
<br />
=== General ===<br />
<br />
* [http://sigfpe.blogspot.com/2006/01/eleven-reasons-to-use-haskell-as.html Eleven Reasons to use Haskell as a Mathematician]<br />
* [http://www.polyomino.f2s.com/ Haskell for Maths]: commutative algebra, combinatorics, number theory, and group theory libraries<br />
* [http://sigfpe.blogspot.com/2006/09/learn-maths-with-haskell.html Learn Maths with Haskell]<br />
* [http://blog.mikael.johanssons.org/archive/2006/10/prototyping-thought/ Prototyping thought]<br />
* [http://scienceblogs.com/goodmath/2006/11/why_haskell.php Why Haskell?]<br />
<br />
=== Calculus and Differential Geometry ===<br />
<br />
* [http://sigfpe.blogspot.com/2006/09/practical-synthetic-differential.html Practical Synthetic Differential Geometry]<br />
* [http://vandreev.wordpress.com/2006/12/04/non-standard-analysis-and-automatic-differentiation/ Non-standard analysis, automatic differentiation, Haskell]<br />
<br />
=== Algebraic Topology and Geometry ===<br />
<br />
* [http://sigfpe.blogspot.com/2006/08/algebraic-topology-in-haskell.html Algebraic Topology in Haskell]<br />
* [http://sigfpe.blogspot.com/2006/09/more-low-cost-geometric-algebra.html More Low Cost Geometric Algebra]<br />
* [http://sigfpe.blogspot.com/2006/08/geometric-algebra-for-free_30.html Geometric Algebra for Free!]<br />
<br />
=== Geometry ===<br />
* [http://www.alpheccar.org/en/posts/show/57 Haskell, PDF and penrose tilings]<br />
<br />
=== Group theory ===<br />
<br />
* [http://blog.mikael.johanssons.org/archive/2006/10/computational-group-theory-in-haskell-1-in-a-series/ Computational Group Theory in Haskell]<br />
* [http://blog.mikael.johanssons.org/archive/2006/07/carry-bits-and-group-cohomology/ Carry bits and group cohomology]<br />
* [http://sigfpe.blogspot.com/2007/06/monads-from-algebra-and-the-gray-code.html Monads from Algebra and the the Gray Code from Groups]<br />
<br />
=== Set theory ===<br />
* Ordinals in Haskell<br />
** [http://japple.blogspot.com/2007/02/countable-ordinals-in-haskell.html Countable ordinals]<br />
** [http://japple.blogspot.com/2007/06/ordinals-part-2.html Uncountable ordinals and better representations for countable ordinals]<br />
* [http://japple.blogspot.com/2007/06/constructability-uncountability-and.html Constructability, Uncountability, and &omega;-Haskell]<br />
* [http://community.livejournal.com/evan_tech/220036.html Defining a power set in one line]<br />
<br />
=== Ring theory ===<br />
* [http://sambangu.blogspot.com/2006/12/polynomials-as-numbers Polynomials] ([http://sambangu.blogspot.com/2006/12/questions-on-haskell-style-and update])<br />
<br />
=== Number theory ===<br />
* [http://cdsmith.wordpress.com/2007/06/24/learning-haskell-and-number-theory-gcd-and-higher-order-functions/ GCD and Higher Order Functions]<br />
<br />
=== Cryptography and coding theory ===<br />
* [http://vandreev.wordpress.com/2007/06/18/feistel-ciphers-and-des-in-haskell/ Feistel Ciphers and DES in Haskell]<br />
* [http://vandreev.wordpress.com/2007/01/07/arithmetic-coding/ Arithmetic coding in Haskell]<br />
* [http://www.serpentine.com/blog/2007/01/11/two-dimensional-spatial-hashing-with-space-filling-curves/ Two-dimensional spatial hashing with space-filling curves]<br />
<br />
=== Logic ===<br />
* [http://sigfpe.blogspot.com/2006/06/laws-of-form-opinion.html Laws of Form: An Opinion]<br />
<br />
=== Numerics ===<br />
* The Division Bell<br />
** [http://praisecurseandrecurse.blogspot.com/2006/12/division-bell-tolls-for-me.html Part One]<br />
** [http://praisecurseandrecurse.blogspot.com/2006/12/division-bell-tolls-for-me-part-two.html Part Two]<br />
** [http://praisecurseandrecurse.blogspot.com/2006/12/division-bell-tolls-for-me-part-three.html Part Three]<br />
** [http://praisecurseandrecurse.blogspot.com/2006/12/division-bell-tolls-for-me-part-four.html Part Four (Conclusion)]<br />
** [http://praisecurseandrecurse.blogspot.com/2006/12/divisive-aftermath.html The Divisive Aftermath]<br />
<br />
* Overloading Haskell numbers<br />
** [http://augustss.blogspot.com/2007/04/overloading-haskell-numbers-part-1.html Part 1: symbolic expressions]<br />
** [http://augustss.blogspot.com/2007/04/overloading-haskell-numbers-part-2.html Part 2: Forward Automatic Differentiation]<br />
** [http://augustss.blogspot.com/2007/04/overloading-haskell-numbers-part-3.html Part 3: Fixed Precision]<br />
** [http://augustss.blogspot.com/2007/05/i-was-asked-if-my-fixed-number-module.html Dynamic epsilons in Haskell with a bit of type hackery]<br />
<br />
== Theorem proving ==<br />
* [http://vandreev.wordpress.com/2006/12/24/quick-and-dirty-theorem-prover/ Quick and Dirty Theorem Prover]<br />
<br />
== Quantum computing ==<br />
<br />
* [http://sigfpe.blogspot.com/2007/02/essence-of-quantum-computing.html The Essence of Quantum Computing]<br />
* [http://sigfpe.blogspot.com/2007/02/monads-for-vector-spaces-probability.html Monads for vector spaces, probability and quantum mechanics pt. I]<br />
* [http://sigfpe.blogspot.com/2007/03/monads-vector-spaces-and-quantum.html Monads, Vector Spaces and Quantum Mechanics pt. II]<br />
* [http://sigfpe.blogspot.com/2007/03/independence-entanglement-and.html Independence, entanglement and decoherence with the quantum monad]<br />
* [http://sigfpe.blogspot.com/2007/03/shor-quantum-error-correcting-code-and.html The Shor Quantum Error Correcting Code (and a Monad for Heat)]<br />
* [http://www.alpheccar.org/en/posts/show/68 The Frame Of Reference Monad]<br />
<br />
== Mathematics of Haskell ==<br />
<br />
=== Category theoretic ===<br />
<br />
* Category Theory and the Category of Haskell programs:<br />
** [http://www.alpheccar.org/en/posts/show/74 Category Theory and the category of Haskell programs]<br />
** [http://www.alpheccar.org/en/posts/show/76 Part 2]<br />
<br />
* [http://sigfpe.blogspot.com/2006/11/why-isnt-listt-monad.html Why isn't ListT list a monad?]<br />
* [http://sigfpe.blogspot.com/2006/11/yoneda-lemma.html Reverse Engineering Machines with the Yoneda Lemma]<br />
* [http://sigfpe.blogspot.com/2006/11/variable-substitution-gives.html Variable substitution gives a...]<br />
* [http://sigfpe.blogspot.com/2006/10/games-strategies-and-self-composition.html Games, Strategies and the Self-Composition of the List Monad.]<br />
<br />
=== Lambda and combinator calculi ===<br />
* [http://scienceblogs.com/goodmath/2006/09/programs_are_proofs_models_and_1.php Programs are Proofs: Models and Types in Lambda Calculus]<br />
* [http://www.onebadseed.com/blog/?p=51 Don't need the Y combinator]<br />
<br />
=== Other formal logics ===<br />
* [http://sigfpe.blogspot.com/2006/11/from-l-theorem-to-spreadsheet.html From Löb's Theorem to Spreadsheet Evaluation]<br />
<br />
=== Miscellaneous ===<br />
* [http://www.rubrication.net/2007/04/21/how-a-real-module-system-should-work/ ML, Haskell and Coq]<br />
* [http://sigfpe.blogspot.com/2006/09/infinitesimal-types.html Infinitesimal Types]<br />
* [http://www.alpheccar.org/en/posts/show/70 Djinn, Coq, Monad and a bit of Haskell]<br />
<br />
[[Category:Tutorials]]<br />
[[Category:Mathematics|*]]</div>Jbapple