https://wiki.haskell.org/api.php?action=feedcontributions&user=Abayley&feedformat=atomHaskellWiki - User contributions [en]2024-03-28T17:27:20ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Existential_type&diff=17642Existential type2007-12-17T13:21:04Z<p>Abayley: </p>
<hr />
<div>__TOC__<br />
This is a extension of Haskell available in [[GHC]]. See the GHC documentation:<br />
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html<br />
<br />
==Introduction to existential types==<br />
<br />
=== Overview ===<br />
<br />
Normally when creating a new type using <hask>type</hask>, <hask>newtype</hask>, <hask>data</hask>, etc., every type variable that appears on the right-hand side must also appear on the left-hand side. Existential types are a way of turning this off.<br />
<br />
=== Basics ===<br />
<br />
Existential types can be ''used'' for several different purposes. But what they ''do'' is to 'hide' a type variable on the right-hand side.<br />
<br />
Normally, any type variable appearing on the right must also appear on the left:<br />
<br />
<haskell><br />
data Worker x y = Worker {buffer :: b, input :: x, output :: y}<br />
</haskell><br />
<br />
This is an error, since the type of the buffer isn't specified on the right (it's a type variable rather than a type) but also isn't specified on the left (there's no 'b' in the left part). In Haskell98, you would have to write<br />
<br />
<haskell><br />
data Worker b x y = Worker {buffer :: b, input :: x, output :: y}<br />
</haskell><br />
<br />
That may or may not be an actual problem.<br />
<br />
Usually there is no problem at all with this state of affairs (which is why Haskell98 works this way). However, suppose that a <hask>Worker</hask> can use ''any'' type 'b' so long as it belongs to some particular class. Then every function that uses a <hask>Worker</hask> will have a type like<br />
<br />
<haskell><br />
foo :: (Buffer b) => Worker b Int Int<br />
</haskell><br />
<br />
or something. (In particular, failing to write an explicit type signature will invoke the dreaded [[monomorphism restriction]].) Using existential types, we can avoid this:<br />
<br />
<haskell><br />
data Worker x y = forall b. Buffer b => Worker {buffer :: b, input :: x, output :: y}<br />
<br />
foo :: Worker Int Int<br />
</haskell><br />
<br />
The type of the buffer now does ''not'' appear in the <hask>Worker</hask> type at all.<br />
<br />
This has a number of consequences. First of all, it is now impossible for a function to demand a <hask>Worker</hask> having a specific type of buffer. Second, the type of <hask>foo</hask> can now be derived automatically without needing an explicit type signature. (No [[monomorphism restriction]].) Thirdly, since code now has ''no idea'' what type the <hask>buffer</hask> function returns, you are more limited in what you can do to it.<br />
<br />
In general, when you use a 'hidden' type in this way, you will usually want that type to belong to a specific class, or you will want to pass some functions along that can work on that type. Otherwise you'll have some value belonging to a random unknown type, and you won't be able to ''do'' anything to it!<br />
<br />
Note: You can use existential types to convert a more specific type into a less specific one. (See the examples below.) There is ''no way'' to perform the reverse conversion!<br />
<br />
== Examples ==<br />
<br />
===A short example===<br />
<br />
This illustrates creating a heterogeneous list, all of whose members implement "Show", and progressing through that list to show these items:<br />
<br />
<haskell><br />
data Obj = forall a. (Show a) => Obj a<br />
<br />
xs = [Obj 1, Obj "foo", Obj 'c']<br />
<br />
doShow :: [Obj] -> String<br />
doShow [] = ""<br />
doShow ((Obj x):xs) = show x ++ doShow xs<br />
</haskell><br />
<br />
With output: <code>doShow xs ==> "1\"foo\"'c'"</code><br />
<br />
===Expanded example - rendering objects in a raytracer===<br />
<br />
====Problem statement====<br />
<br />
In a raytracer, a requirement is to be able to render several different objects (like a ball, mesh or whatever). The first step is a type class for Renderable like so:<br />
<br />
<haskell><br />
class Renderable a where<br />
boundingSphere :: a -> Sphere<br />
hit :: a -> [Fragment] -- returns the "fragments" of all hits with ray<br />
{- ... etc ... -}<br />
</haskell><br />
<br />
To solve the problem, the <hask>hit</hask> function must apply to several objects (like a sphere and a polygon for instance).<br />
<br />
<haskell><br />
hits :: Renderable a => [a] -> [Fragment]<br />
hits xs = sortByDistance $ concatMap hit xs<br />
</haskell><br />
<br />
However, this does not work as written since the elements of the list can be of '''SEVERAL''' different types (like a sphere and a polygon and a mesh etc. etc.) but<br />
lists need to have elements of the same type.<br />
<br />
====The solution====<br />
<br />
Use 'existential types' - an extension to Haskell that can be found in most compilers.<br />
<br />
The following example is based on GHC :<br />
<br />
<haskell><br />
{-# OPTIONS -fglasgow-exts #-}<br />
<br />
{- ...-}<br />
<br />
data AnyRenderable = forall a. Renderable a => AnyRenderable a<br />
<br />
instance Renderable AnyRenderable where<br />
boundingSphere (AnyRenderable a) = boundingSphere a<br />
hit (AnyRenderable a) = hit a<br />
{- ... -}<br />
</haskell><br />
<br />
Now, create lists with type <hask>[AnyRenderable]</hask>, for example,<br />
<haskell><br />
[ AnyRenderable x<br />
, AnyRenderable y<br />
, AnyRenderable z ]<br />
</haskell><br />
where x, y, z can be from different instances of <hask>Renderable</hask>.<br />
=== Dynamic dispatch mechanism of OOP ===<br />
<br />
'''Existential types''' in conjunction with type classes can be used to emulate the dynamic dispatch mechanism of object oriented programming languages. To illustrate this concept I show how a classic example from object oriented programming can be encoded in Haskell.<br />
<br />
<haskell><br />
class Shape_ a where<br />
perimeter :: a -> Double<br />
area :: a -> Double<br />
<br />
data Shape = forall a. Shape_ a => Shape a<br />
<br />
type Radius = Double<br />
type Side = Double<br />
<br />
data Circle = Circle Radius<br />
data Rectangle = Rectangle Side Side<br />
data Square = Square Side<br />
<br />
<br />
instance Shape_ Circle where<br />
perimeter (Circle r) = 2 * pi * r<br />
area (Circle r) = pi * r * r<br />
<br />
instance Shape_ Rectangle where<br />
perimeter (Rectangle x y) = 2*(x + y)<br />
area (Rectangle x y) = x * y<br />
<br />
instance Shape_ Square where<br />
perimeter (Square s) = 4*s<br />
area (Square s) = s*s<br />
<br />
instance Shape_ Shape where<br />
perimeter (Shape shape) = perimeter shape<br />
area (Shape shape) = area shape<br />
<br />
<br />
--<br />
-- Smart constructor<br />
--<br />
<br />
circle :: Radius -> Shape<br />
circle r = Shape (Circle r)<br />
<br />
rectangle :: Side -> Side -> Shape<br />
rectangle x y = Shape (Rectangle x y)<br />
<br />
square :: Side -> Shape<br />
square s = Shape (Square s)<br />
<br />
shapes :: [Shape]<br />
shapes = [circle 2.4, rectangle 3.1 4.4, square 2.1]<br />
</haskell><br />
<br />
(You may see other [[Smart constructors]] for other purposes).<br />
<br />
=== [[Generalised algebraic datatype]] ===<br />
<br />
The type of the <hask>parse</hask> function for [[Generalised algebraic datatype#Motivating example|this GADT]] is a good example to illustrate the concept of existential type.<br />
<br />
==Alternate methods==<br />
===Concrete data types===<br />
====Universal instance of a Class====<br />
Here one way to simulate existentials (Hawiki note: (Borrowed from somewhere...))<br />
<br />
<br />
Suppose I have a type class Shape a<br />
<haskell><br />
type Point = (Float,Float)<br />
<br />
class Shape a where<br />
draw :: a -> IO ()<br />
translate :: a-> Point -> a<br />
<br />
</haskell><br />
<br />
Then we can pack shapes up into a [[concrete data type]] like this:<br />
<haskell><br />
data SHAPE = SHAPE (IO ()) (Point -> SHAPE)<br />
</haskell><br />
with a function like this<br />
<haskell><br />
packShape :: Shape a => a -> SHAPE<br />
packShape s = SHAPE (draw s) (\(x,y) -> packShape (translate s (x,y)))<br />
</haskell><br />
This would be useful if we needed a list of shapes that we would need to translate and draw.<br />
<br />
In fact we can make <hask>SHAPE</hask> an instance of <hask>Shape</hask>:<br />
<haskell><br />
instance Shape SHAPE where<br />
draw (SHAPE d t) = d<br />
translate (SHAPE d t) = t<br />
</haskell><br />
<br />
So SHAPE is a sort of universal instance.<br />
<br />
====Using constructors and combinators====<br />
Why bother with class <hask>Shape</hask>? Why not just go straight to<br />
<br />
<haskell><br />
data Shape = Shape {<br />
draw :: IO()<br />
translate :: (Int, Int) -> Shape<br />
}<br />
</haskell><br />
<br />
Then you can create a library of shape [[constructor]]s and [[combinator]]s<br />
that each have defined "draw" and "translate" in their "where" clauses.<br />
<br />
<haskell><br />
circle :: (Int, Int) -> Int -> Shape<br />
circle (x,y) r =<br />
Shape draw1 translate1<br />
where<br />
draw1 = ...<br />
translate1 (x1,y1) = circle (x+x1, y+y1) r<br />
<br />
shapeGroup :: [Shape] -> Shape<br />
shapeGroup shapes = Shape draw1 translate1<br />
where<br />
draw1 = sequence_ $ map draw shapes<br />
translate1 v = shapeGroup $ map (translate v) shapes<br />
</haskell><br />
<br />
===Cases that really require existentials===<br />
<br />
There are cases where this sort of trick doesnt work. Here are two examples from a haskell mailing list discussion (from K. Claussen) that don't seem expressible without<br />
existentials. (But maybe one can rethink the whole thing :)<br />
<haskell><br />
data Expr a = Val a | forall b . Apply (Expr (b -> a)) (Expr b)<br />
</haskell><br />
and<br />
<haskell><br />
data Action = forall b . Act (IORef b) (b -> IO ())<br />
</haskell><br />
(Maybe this last one could be done as a <hask>type Act (IORef b) (IORef b -> IO ())</hask> then we could hide the <hask>IORef</hask> as above, that is go ahead and apply the second argument to the first)<br />
<br />
== Examples from the [http://www.cs.uu.nl/wiki/Ehc/ Essential Haskell Compiler] project ==<br />
<br />
See the [http://www.cs.uu.nl/wiki/Ehc/#On_EHC documentation on EHC], each paper at the ''Version 4'' part:<br />
* Chapter 8 (EH4) of Atze Dijkstra's [http://www.cs.uu.nl/groups/ST/Projects/ehc/ehc-book.pdf Essential Haskell PhD thesis] (most recent version). A detailed explanation. It explains also that existential types can be expressed in Haskell, but their use is restricted to data declarations, and the notation (using keyword <hask>forall</hask>) may be confusing. In Essential Haskell, existential types can occur not only in data declarations, and a separate keyword <hask>exists</hask> is used for their notation.<br />
* [http://www.cs.uu.nl/wiki/pub/Ehc/WebHome/20050107-eh-intro.pdf Essential Haskell Compiler overview]<br />
* [http://www.cs.uu.nl/wiki/Ehc/Examples#EH_4_forall_and_exists_everywher Examples]<br />
<br />
==See also==<br />
* A mailinglist discussion: http://haskell.org/pipermail/haskell-cafe/2003-October/005231.html<br />
* An example of encoding existentials using RankTwoPolymorphism: http://haskell.org/pipermail/haskell-cafe/2003-October/005304.html<br />
* Another mailing list discussion (functional vs OO approaches): http://www.haskell.org/pipermail/haskell/2005-June/016058.html<br />
=== Trac ===<br />
<br />
[http://hackage.haskell.org/trac/haskell-prime/wiki/ExistentialQuantification Existential Quantification] is a detailed material on the topic. It has link also to the smaller [http://hackage.haskell.org/trac/haskell-prime/wiki/ExistentialQuantifier Existential Quantifier] page.<br />
<br />
[[Category:Idioms]]<br />
[[Category:Glossary]]<br />
[[Category:Language extensions]]</div>Abayleyhttps://wiki.haskell.org/index.php?title=Non-strict_semantics&diff=16909Non-strict semantics2007-11-19T14:17:52Z<p>Abayley: </p>
<hr />
<div>'''Non-strict semantics''' means that a function can have a definite value although its argument is undefined.<br />
E.g. in Haskell you get<br />
<br />
<haskell><br />
Prelude> True || undefined<br />
True<br />
</haskell><br />
<br />
You will not be able to define a function <code>or</code> say in C which returns something if you pass an undefined value (e.g. one that is the result of an infinite loop). In fact, in <code>or(true,infinite_loop())</code>, the code of <code>or</code> will never be run. In Haskell it is possible because you [[Call by demand]].<br />
<br />
==See also==<br />
<br />
* Jonathan Cast in Haskell Cafe about [http://www.haskell.org/pipermail/haskell-cafe/2007-November/034807.html What is the role of $! ?]<br />
<br />
* [[Lazy vs. non-strict]]<br />
<br />
[[Category:Glossary]]</div>Abayleyhttps://wiki.haskell.org/index.php?title=Video_presentations&diff=14725Video presentations2007-07-29T06:16:09Z<p>Abayley: </p>
<hr />
<div>Collected videos of Haskell tutorials and conference presentations,<br />
sorted by topic.<br />
<br />
== Introductions to FP and Haskell ==<br />
<br />
;[http://channel9.msdn.com/showpost.aspx?postid=326762 Programming language nirvana]<br />
:Simon Peyton-Jones, Eric Meijer, MSR, July 2007.<br />
<br />
;[http://video.google.com/videoplay?docid=-4167170843018186532 Faith, Evolution, and Programming Languages]<br />
:Phil Wadler, April 2007.<br />
<br />
== Advanced topics ==<br />
<br />
;[http://video.google.com/videoplay?docid=-4851250372422374791 Parametric Polymorphism and the Girard-Reynolds Isomorphism]<br />
:Phil Gossett, April 2007.<br />
<br />
== Concurrency and parallelism ==<br />
<br />
;[http://www.blip.tv/file/317758/ Transactional Memory for Concurrent Programming]<br />
:Simon Peyton-Jones, OSCON, July 2007.<br />
<br />
;[http://channel9.msdn.com/Showpost.aspx?postid=231495 Programming in the Age of Concurrency: Software Transactional Memory]<br />
:Simon Peyton-Jones and Tim Harris, September 2006.<br />
<br />
;[http://video.google.co.uk/videoplay?docid=370317485066035666&hl=en-GB Nested Data Parallelism in Haskell]<br />
:Simon Peyton-Jones, London-HUG, May 2007.<br />
<br />
== The ICFP contest ==<br />
<br />
;[http://video.google.com/videoplay?docid=641909436975618453 2006 ICFP contest results]<br />
:ICFP, 2006<br />
<br />
== Livecoding Haskell ==<br />
<br />
;[http://youtube.com/watch?v=xaoLbKWMwoU Haskell music]<br />
:[http://doc.gold.ac.uk/~ma503am/ Yaxu], 2006.<br />
<br />
;[http://youtube.com/watch?v=eLS6GHXWMpA Hacking Haskell music]<br />
:More of Yaxu live coding music and Haskell, 2006.<br />
<br />
== GHC Hackathon presentations ==<br />
<br />
;[http://hackage.haskell.org/trac/ghc/wiki/AboutVideos GHC commentary]<br />
:Simon Peyton Jones and Simon Marlow, 2006.<br />
<br />
[[Category:Tutorials]]</div>Abayleyhttps://wiki.haskell.org/index.php?title=Libraries_and_tools/Time_library&diff=4860Libraries and tools/Time library2006-07-17T10:51:51Z<p>Abayley: </p>
<hr />
<div>[http://haskell.org/ghc/dist/current/docs/libraries/time/Data-Time.html Data.Time], now in the base libraries and due to be released with GHC 6.6. Homepage: [http://semantic.org/TimeLib/ TimeLib]<br />
<br />
The API is well designed, but not particularly obvious for simple use cases. Hopefully we can collect a number of common examples here.<br />
<br />
<br />
----<br />
<br />
<br />
If you want to use Data.Time with GHC 6.4, you will need to install a number of libraries it depends on first. The process is:<br />
<br />
darcs get --partial http://www.cse.unsw.edu.au/~dons/code/fps<br />
normal cabal configure, build, install<br />
<br />
darcs get http://darcs.haskell.org/packages/Win32<br />
Edit Win32.cabal, add fps to build-depends.<br />
normal cabal configure, build, install<br />
<br />
darcs get http://semantic.org/TimeLib/TimeLib<br />
There are two packages here: time and fixed. Ignore time.<br />
Go into fixed and do cabal configure, build, install<br />
<br />
darcs get http://darcs.haskell.org/packages/time<br />
Edit time.cabal, add fixed and Win32 to build-depends.<br />
create Setup.hs:<br />
import Distribution.Simple<br />
main = defaultMainWithHooks defaultUserHooks<br />
From MSYS shell, not Windows cmd.exe:<br />
autoreconf<br />
runhaskell Setup.hs configure<br />
runhaskell Setup.hs build<br />
runhaskell Setup.hs install</div>Abayleyhttps://wiki.haskell.org/index.php?title=Applications_and_libraries/Operating_system&diff=4859Applications and libraries/Operating system2006-07-17T10:51:05Z<p>Abayley: </p>
<hr />
<div>'''Operating Systems and Systems Programming'''<br />
<br />
__TOC__<br />
<br />
== Standalone implementations of operating systems in Haskell ==<br />
<br />
;[http://www.cse.ogi.edu/~hallgren/House/ House]<br />
:House is a platform for exploring various ideas relating to low-level and system-level programming in a high-level functional language, or in short for building operating systems in Haskell. <br />
<br />
== Filesystems ==<br />
<br />
;[http://www.haskell.org/halfs/ Halfs, the Haskell Filesystem]<br />
:Halfs is a filesystem implemented in Haskell. Halfs can be mounted and used like any other Linux filesystem, or used as a library.<br />
<br />
;[http://abridgegame.org/repos/fuse_example Fuse] <br />
:David Roundy's combination of a nice DarcsIO-style filesystem interface on the Haskell side (called FuseIO) with an interface to libfuse (which is a library for creating filesystems from user space on linux).<br />
<br />
;[http://cvs.haskell.org/darcs/hfuse/ hfuse]<br />
:Jeremy Bobbio's fuse bindings<br />
<br />
;[http://okmij.org/ftp/Computation/Continuations.html#zipper-fs ZipperFS] <br />
:Oleg Kiselyov's file server/OS where threading and exceptions are all realized via delimited continuations.<br />
<br />
;[http://article.gmane.org/gmane.comp.lang.haskell.general/13585 Debian From Scratch]<br />
:A single, full debian rescue CD. The tool that generates these ISO images (dfsbuild) is written in Haskell.<br />
<br />
== Hardware emulators ==<br />
<br />
;[http://www.mutantlemon.com/omegagb/ OmegaDB]<br />
:OmegaGB is a Nintendo Game Boy emulator written in Haskell.<br />
<br />
== Dynamic linking ==<br />
<br />
;[http://www.cse.unsw.edu.au/~dons/hs-plugins hs-plugins] <br />
:Library support for dynamically loading Haskell modules, as well as compiling source or ''eval'' code fragments at runtime.<br />
<br />
== Processes ==<br />
<br />
;[http://www.haskell.org/~petersen/haskell/popenhs/ popenhs]<br />
:A small library, based on runProcess in the standardised posix library. It provides lazy output from subprocesses.<br />
<br />
;[http://freearc.narod.ru/ Process]<br />
:Process is a fun library for easing decomposition of algorithms to several processes, which transmit intermediate data via Unix-like pipes. Each sub-process is just a function started with forkIO/forkOS with one additional parameter-pipe.<br />
<br />
See also [[Libraries_and_tools/Concurrency_and_parallelism]]<br />
<br />
== Environment ==<br />
<br />
;[http://repetae.net/john/recent/out/GetOptions.html GetOptions]<br />
:This module provides an advanced option parsing routine which can properly parse options depending on what types are infered for them as well as produce a pretty error message with usage info when an incorrect option is used.<br />
<br />
== Time ==<br />
<br />
;[http://semantic.org/TimeLib/ TimeLib]<br />
:TimeLib is an attempt to redesign the current library for handling time (System.Time), balancing expressive functionality and intelligible simplicity. Now at version 0.2, TimeLib features representation of TAI, UTC and UT1, as well as Gregorian, ISO 8601 week, and "year and day" calendars, time-zones, and functions for strftime-style formatting. We'd like to collect some additional documentation on this wiki, too: [[Libraries_and_tools/TimeLibrary]]<br />
<br />
;[http://www.cs.chalmers.se/~bringert/darcs/parsedate/doc/ ParseDate]<br />
:ParseDate provides a function for parsing dates and times given a date format string.<br />
<br />
== Shell ==<br />
<br />
=== Link collections on pure functional shells ===<br />
<br />
* [http://lambda-the-ultimate.org/classic/message9846.html on Lambda the Ultimate]<br />
* [http://www.cse.unsw.edu.au/~pls/thesis-topics/functionalshell.html Thesis Topic: The Design and Implementation of a Functional Shell]<br />
<br />
=== Haskell shell examples ===<br />
<br />
;[http://www.volker-wysk.de/hsshellscript HsShellScript]<br />
:A library for using Haskell for tasks which are usually done by shell scripts, e.g. command line parsing, analysing paths, etc. It can be used also for tasks usually done [http://haskell.org/ghc/docs/latest/html/libraries/base/System-Console-GetOpt.html GetOpt] (a module for GNU-/POSIX-like option handling of commandline arguments). But also for many other things.<br />
<br />
;[http://www.informatik.uni-bonn.de/~ralf/software/examples/Hsh.html Jim Mattson's Hsh Haskell shell]<br />
:on the [http://www.informatik.uni-bonn.de/~ralf/software.html software] page by [http://www.informatik.uni-bonn.de/~ralf/ Ralf Hinze]. Hsh seems to be written in Haskell 1.3.<br />
<br />
;[http://nellardo.com/lang/haskell/hash/ HaSh]<br />
:a nascent project page on a shell scripting system<br />
<br />
;[http://okmij.org/ftp/Computation/monadic-shell.html Monadic i/o and UNIX shell programming]<br />
:UNIX pipes as IO monads.<br />
<br />
;[http://directory.fsf.org/shell-haskell.html shell-haskell]<br />
:library for communicating with other processes via Haskell code<br />
<br />
;[http://haskell.org/hashell hashell]<br />
:shell with some scripting capabilities to use Haskell as a scripting language.<br />
<br />
;[http://www.haskell.org/pipermail/haskell/2006-June/018059.html Haskell Shell (HSH)]<br />
:HSH, the Haskell shell. Things are still very preliminary in many ways, but this version already lets you:<br />
* Run commands<br />
* Pipe things between commands<br />
* Pipe command input/output into and out of pure Haskell functions<br />
* Pure Haskell functions are as much a first-class citizen as is grep or cat<br />
<br />
== Shell utilities ==<br />
<br />
;[http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/haskell-ls/ haskell-ls]<br />
:A (near-)clone of the GNU ls utility.<br />
<br />
;[http://www.cse.unsw.edu.au/~dons/h4sh.html h4sh]<br />
:h4sh provides a set of Haskell List functions as normal unix shell commands. This allows us to use Haskell in shell scripts transparently. Each program is generated from the corresponding Haskell function's type<br />
<br />
== Package Management ==<br />
<br />
;[http://www.haskell.org/~luisfaraujo/himerge hImerge]<br />
:Luis Araujo's Haskell gui frontend to Emerge<br />
<br />
== File utilities ==<br />
<br />
;[http://quux.org/devel/magic-haskell magic-haskell]<br />
:magic-haskell is a binding to the libmagic library. With magic-haskell, you can determine the type of a file by looking at its contents rather than its name. This library also can yield the MIME type of a file by looking at its contents.<br />
<br />
;[http://www.cse.unsw.edu.au/~dons/code/icfp05/MkTemp.hs mkstemps]<br />
:A Haskell reimplementation of the C mktemp/mkstemp/mkstemps library from OpenBSD<br />
<br />
;[http://www.cse.unsw.edu.au/~dons/haskell-1990-2000/msg04763.html Unix.hs]<br />
:Koen Claessen's binding to common unix functions.<br />
<br />
== Logging ==<br />
<br />
;[http://repetae.net/john/recent/out/ErrorLog.html ErrorLog]<br />
:Manages an error log with proper locking. has a number of useful routines for detecting and reporting erronious conditions.<br />
<br />
;[http://www.cse.unsw.edu.au/~dons/code/icfp05/Logging.hs Logging]<br />
:Multiple debug levels and log file support<br />
<br />
24 entries.</div>Abayleyhttps://wiki.haskell.org/index.php?title=Libraries_and_tools/Time_library&diff=4858Libraries and tools/Time library2006-07-17T10:44:36Z<p>Abayley: </p>
<hr />
<div>[http://haskell.org/ghc/dist/current/docs/libraries/time/Data-Time.html Data.Time], now in the base libraries and due to be released with GHC 6.6.<br />
<br />
The API is well designed, but not particularly obvious for simple use cases. Hopefully we can collect a number of common examples here.<br />
<br />
<br />
----<br />
<br />
<br />
If you want to use Data.Time with GHC 6.4, you will need to install a number of libraries it depends on first. The process is:<br />
<br />
darcs get --partial http://www.cse.unsw.edu.au/~dons/code/fps<br />
normal cabal configure, build, install<br />
<br />
darcs get http://darcs.haskell.org/packages/Win32<br />
Edit Win32.cabal, add fps to build-depends.<br />
normal cabal configure, build, install<br />
<br />
darcs get http://semantic.org/TimeLib/TimeLib<br />
There are two packages here: time and fixed. Ignore time.<br />
Go into fixed and do cabal configure, build, install<br />
<br />
darcs get http://darcs.haskell.org/packages/time<br />
Edit time.cabal, add fixed and Win32 to build-depends.<br />
create Setup.hs:<br />
import Distribution.Simple<br />
main = defaultMainWithHooks defaultUserHooks<br />
From MSYS shell, not Windows cmd.exe:<br />
autoreconf<br />
runhaskell Setup.hs configure<br />
runhaskell Setup.hs build<br />
runhaskell Setup.hs install</div>Abayleyhttps://wiki.haskell.org/index.php?title=Libraries_and_tools/Time_library&diff=4857Libraries and tools/Time library2006-07-17T10:43:45Z<p>Abayley: </p>
<hr />
<div>Now in the base libraries, due to be released with GHC 6.6.<br />
[http://haskell.org/ghc/dist/current/docs/libraries/time/Data-Time.html Data.Time]<br />
<br />
<br />
The API is well designed, but not particularly obvious for simple use cases. Hopefully we can collect a number of common examples here.<br />
<br />
If you want to use Data.Time with GHC 6.4, you will need to install a number of libraries it depends on first. The process is:<br />
<br />
darcs get --partial http://www.cse.unsw.edu.au/~dons/code/fps<br />
normal cabal configure, build, install<br />
<br />
darcs get http://darcs.haskell.org/packages/Win32<br />
Edit Win32.cabal, add fps to build-depends.<br />
normal cabal configure, build, install<br />
<br />
darcs get http://semantic.org/TimeLib/TimeLib<br />
There are two packages here: time and fixed. Ignore time.<br />
Go into fixed and do cabal configure, build, install<br />
<br />
darcs get http://darcs.haskell.org/packages/time<br />
Edit time.cabal, add fixed and Win32 to build-depends.<br />
create Setup.hs:<br />
import Distribution.Simple<br />
main = defaultMainWithHooks defaultUserHooks<br />
From MSYS shell, not Windows cmd.exe:<br />
autoreconf<br />
runhaskell Setup.hs configure<br />
runhaskell Setup.hs build<br />
runhaskell Setup.hs install</div>Abayleyhttps://wiki.haskell.org/index.php?title=Applications_and_libraries/Database_interfaces&diff=4856Applications and libraries/Database interfaces2006-07-17T10:36:24Z<p>Abayley: </p>
<hr />
<div>{{unknown copyright}}<br />
{{LibrariesPage}}<br />
<br />
__TOC__<br />
<br />
== Related concepts ==<br />
<br />
[[Relational algebra]]<br />
<br />
== Haskell Database Libraries ==<br />
<br />
;[http://sourceforge.net/forum/forum.php?forum_id=350240 HSQL]<br />
:HSQL is a simple library which provides an interface to multiple databases. MySQL, PostgreSQL, ODBC, SQLite and Oracle are currently supported. It is part of [http://htoolkit.sourceforge.net/ HToolkit].<br />
<br />
;[http://darcs.haskell.org/takusen Takusen]<br />
:A library to interface to Oracle, Sqlite, and Postgres, with an API based on a left-fold enumerator. Now hosted at [http://darcs.haskell.org/takusen darcs.haskell.org].<br />
<br />
;HaskellDB<br />
:[[/HaskellDB|See a separate Haskell Wiki page on it]]. Daan Leijen's [http://www.haskell.org/haskellDB original] HaskellDB, and an [http://haskelldb.sourceforge.net/ updated] version that works with current Haskell implementations and is relatively platform-independent. HaskellDB is a combinator library for expressing queries and other operations on relational databases in a type safe and declarative way. All the queries and operations are completely expressed within Haskell, no embedded (SQL) commands are needed. This close integration makes it possible to do arbitrary computations on the database (like computing the transitive closure).<br />
<br />
;[http://wiki.di.uminho.pt/wiki/bin/view/PURe/CoddFish CoddFish]<br />
:[[/CoddFish|See a separate Haskell Wiki page on it]]. It is another type safe and declarative approach to database managament in Haskell.<br />
<br />
;[http://quux.org/devel/hdbc HDBC]<br />
: HDBC is modeled loosely on Perl's DBI interface, though it has also been influenced by Python's DB-API v2, JDBC in Java, and HSQL in Haskell. <br />
<br />
;[http://members.tripod.com/~sproot/hasql.htm HaSQL]<br />
:HaSQL is a Haskell to ODBC interface. HaSQL allows Haskell program to run SQL queries against an ODBC compliant database. Queries with parameters are supported. Data is retrieved from the database as a lazy list.<br />
<br />
;[http://www.astercity.net/~khaliff/haskell/dbi/dbi.tgz libpq binding]<br />
:A Haskell binding to libpq, a client-side PostgreSQL programming library, together with a simple DBI for Haskell. It enables the programmer to write database-independent code.<br />
<br />
;[http://wiki.di.uminho.pt/wiki/bin/view/PURe/VooDooM VooDooM]<br />
:VooDooM reads VDM-SL specifications and applies transformation rules to the datatypes that are defined in them to obtain a relational representation for these datatypes. The relational representation can be exported as VDM-SL datatypes (inserted back into the original specification) or SQL table definitions (which can be fed to a relational DBMS)<br />
<br />
;[http://www.volker-wysk.de/mysql-hs/ MySQL-HS]<br />
:MySQL-HS is an interface to the MySQL database.</div>Abayleyhttps://wiki.haskell.org/index.php?title=Talk:History_of_Haskell/Version_1&diff=4842Talk:History of Haskell/Version 12006-07-17T07:37:14Z<p>Abayley: </p>
<hr />
<div>== Comments on "The History of Haskell" (draft) ==<br />
<br />
Please use the Wiki to add your comments here. Include your name and the date. You can do this with four tildes, like this: <nowiki>~~~~</nowiki>.<br />
<br />
To edit the page, you need to log in: click the login link at the bottom of the window. If you don't already have an account, the login page lets you create one in 30 seconds. See [[HaskellWiki:Contributing]].<br />
<br />
-----------------<br />
<br />
== Administration ==<br />
<br />
[[User:Simonpj|Simonpj]] 18:51, 14 July 2006 (UTC) Simon PJ. Here is an example comment<br />
<br />
[[User:BerniePope|BerniePope]] I hope you don't mind, but I've taken the liberty of breaking this up into sections, so that it is easier to find out what has been said already. This seems to be especially useful for typos etc. Please feel free to add other sections if you think they are necessary. I've also made the page numbers bold, and put them into page order (where possible).<br />
<br />
== Title suggestions ==<br />
<br />
[[User:JaredUpdike|JaredUpdike]] 20:38, 14 July 2006 (UTC) Other ideas for a title: ''The History of Haskell: Unsuccessfully Avoiding Success'' or something using the motto "Avoid success at all costs." Or perhaps ''Success Considered Harmful, or, A History of Haskell'' or ''Doomed to Succeed'' quoting Hoare (although this sounds somewhat self-congratulatory).<br />
<br />
[[User:GaneshSittampalam|GaneshSittampalam]] 09:19, 15 July 2006 (UTC) I really like the "eager to be lazy" title.<br />
<br />
== Typos, spelling, grammar, formatting and expression ==<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Typo: '''page 2''', column 2, "Rod Bustall" should be "Rod Burstall".<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Spelling: '''page 3''', column 1, "confernce".<br />
<br />
On '''page 4''' after the list of goals, it seems that the following sentence ("We agreed to base it on an existing language,<br />
namely OL.") should be preceeded by a line break (it now starts on the same line as the sixth goal).<br />
<br />
[[User:JaredUpdike|JaredUpdike]] 22:00, 14 July 2006 (UTC) '''page 9''' Section 3.8, last paragraph, syntax error: should be "Miranda is still in use today: it '''is''' still taught in some institutions", missing word. (Sec 4.2 ''This tradition was honed by Moses Schonfinkel and Haskell Curry, and came to be called currying.'' I half expected a joke following this, saying ''[it was] called currying, luckily, and not '''schonfinkeling'''.'') Same section, typo: ''is a list of lists'' should be ''in a list of lists.''<br />
:That joke would have been surpassed by reality, because the german word for ''currying'' '''is''' ''schönfinkeln''. See [http://de.wikipedia.org/wiki/Sch%C3%B6nfinkeln Schönfinkeln]. --[[User:MarcVanWoerkom|MarcVanWoerkom]] 18:49, 16 July 2006 (UTC)<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Expression. '''page 9'''. It says "Haskell did not adopt Miranda's abstract data types, using '''its''' module system instead." It is not clear whose module system it is using. Perhaps it should read "using '''a''' module system instead." ?<br />
<br />
[[User:BerniePope|BerniePope]] 15:56, 15 July 2006 (UTC) Tense. '''page 12'''. Section 5.1, algebraic data types. It says "In general, every algebraic data type specified...", should that be "specifies" ? or perhaps even better "In general, algebraic data types specify" ?<br />
<br />
[[User:Ruiz|Ruiz]] 12:04, 16 July 2006 (UTC) Comment. '''page 12'''. If I am not mistaken, the Fermat's Last Theorem example only generates (1,1,z) triplets.<br />
<br />
[[User:BerniePope|BerniePope]] 16:15, 15 July 2006 (UTC) Tense. '''page 13'''. Section 5.3 Abstract types. It says "This had the advantage ...". Perhaps it should be: "This has the advantage", since Miranda still exists, and the advantage still holds. Later in the same paragraph the expression about adopting the feature in Haskell is a bit awkward. Perhaps it could read: "It is not clear how to adapt Miranda's method of defining abstract data types to type classes, and that is one reason we chose a different solution." ?<br />
<br />
[[User:BerniePope|BerniePope]] 16:27, 15 July 2006 (UTC) Typo. Section 5.6, '''page 14''' and in Bibliography. Godel's name in citation missing the 'o'.<br />
<br />
[[User:BerniePope|BerniePope]] 05:41, 16 July 2006 (UTC) Comment. '''page 15''', column 1. "practical comprehensibility" is a bit of a mouthful. Perhaps "pragmatism" would suffice?<br />
<br />
[[User:BerniePope|BerniePope]] 06:11, 16 July 2006 (UTC) Typo (possibly). '''page 16'''. Section 6.4, multi-parameter type classes. "They gave the following example: second.". Should the "second" be there?<br />
<br />
[[User:BerniePope|BerniePope]] 06:56, 16 July 2006 (UTC) Typo, '''page 16'''. The code "n = (x + y)", perhaps drop the redundant parens?<br />
<br />
[[User:BerniePope|BerniePope]] 07:19, 16 July 2006 (UTC) '''page 17'''. Choice of identifier. In the code "f (MkT x f) = f x". Perhaps the inner or outer "f" should be renamed? Also, is there a more compelling example than this one?<br />
<br />
[[User:Weihu|Weihu]] 17:33, 16 July 2006 (UTC) '''page 17'''. Duplication of words. "The the type qualification in this case" => "The type qualification in this case".<br />
<br />
[[User:BerniePope|BerniePope]] 07:16, 16 July 2006 (UTC) Typo. '''page 17'''. "patter-matching" -> "pattern-matching".<br />
<br />
[[User:BerniePope|BerniePope]] 07:26, 16 July 2006 (UTC) Expression. '''page 17'''. Perhaps drop "rather than explicitly". This is implied by the previous "happens implicitly".<br />
<br />
[[User:BerniePope|BerniePope]] 07:38, 16 July 2006 (UTC) Typo. '''page 18'''. In lexically scoped type variables, it says the type of xcons is "forall a. a -> a". Do you mean: "forall a . [a] -> [a]"?<br />
<br />
[[User:BerniePope|BerniePope]] 08:39, 16 July 2006 (UTC) Typesetting. '''page 22'''. Sometimes the "IO monad" is written where "IO" is in typewriter font, and other times it is in times roman, and other times it is written "I/O". This may be an intentional distinction, but maybe the notation can be unified?<br />
<br />
[[User:Weihu|Weihu]] 20:36, 16 July 2006 (UTC) Word missing. '''page 22'''. "So readFile a function that" => "So readFile is a function that".<br />
<br />
[[User:JaredUpdike|JaredUpdike]] 04:27, 15 July 2006 (UTC) '''page 25'''. Section 9.2 misspelling "existance" should be "existence" third to last paragraph. Sec. 9.5 , '''page 27''', second to last paragraph. ''test bad'' should be ''test bed''.<br />
<br />
[[User:BerniePope|BerniePope]] 12:33, 16 July 2006 (UTC) Typo. '''page 28'''. Section 10.2, paragraph 2. "who had by thus time" -> "who had by this time".<br />
<br />
[[User:BerniePope|BerniePope]] 13:22, 16 July 2006 (UTC) Missing word. '''page 30'''. Section 10.4.2 Observational debugging. It says "to track down bug location" -> "to track down '''the''' bug location".<br />
<br />
[[User:BerniePope|BerniePope]] 05:07, 17 July 2006 (UTC) Expression. '''page 30'''. Section 10.5 Testing tools. "If debugging tools ... -> "Whilst debugging tools ...". The "if" seems to be left hanging in the sentence.<br />
<br />
[[User:BerniePope|BerniePope]] 05:30, 17 July 2006 (UTC) Syntax. '''page 30'''. Section 10.5 Testing tools. In the definition of "prop_insert" you use "$" for infix application, and thus avoid some parens. I wonder whether it would be better to have the explicit parens instead? Non Haskellers may find the "$" style difficult to parse. Also, it would be more consistent with other example pieces of code in the paper.<br />
<br />
[[User:Weihu|Weihu]] 21:35, 15 July 2006 (UTC) Typo: '''page 31''', column 2, "a central them" should be "a central theme".<br />
<br />
[[User:BerniePope|BerniePope]] 05:47, 17 July 2006 (UTC) Typo. '''page 33'''. Section 11.2.1 Functional reactive programming. The instance declaration for Floating is missing "Behaviour a) where".<br />
<br />
[[User:GaneshSittampalam|GaneshSittampalam]] 09:18, 15 July 2006 (UTC) Section 11.2.3 '''page 34''' typo "unsagePerformIO".<br />
<br />
[[User:BerniePope|BerniePope]] 06:44, 17 July 2006 (UTC) Missing word (perhaps). '''page 34'''. Section 11.2.5 Summary. It says "... a DSEL is little than that." I have not heard that expression before, perhaps it was meant to be: "... a DSEL is little '''more''' than that."? <br />
<br />
[[User:BerniePope|BerniePope]] 06:51, 17 July 2006 (UTC) Typo. '''page 35'''. Section 11.3 Graphical user interfaces. "lacked the fully range of widgets" -> "lacked the '''full''' range of widgets".<br />
<br />
[[User:BerniePope|BerniePope]] 06:54, 17 July 2006 (UTC) Extra word. '''page 35'''. Section 11.3 Graphical user interfaces. "... and '''only''' implemented '''only''' part of the full interface."<br />
<br />
[[User:Weihu|Weihu]] 21:42, 16 July 2006 (UTC) '''page 35''': "invariably based on a imperative widget" => "invariably based on an imperative widget".<br />
<br />
[[User:BerniePope|BerniePope]] 06:54, 17 July 2006 (UTC) Typo. '''page 35'''. Section 11.4 Natural language processing. "Callaghan?s": there is a question mark where there ought to be an apostrophe.<br />
<br />
[[User:BerniePope|BerniePope]] 07:07, 17 July 2006 (UTC) Notation. '''page 36'''. Section 12.1 Education. You write "embedded DSLs", earlier in Section 11.2 you use the acronym "DSEL" perhaps for the same thing?<br />
<br />
[[User:BerniePope|BerniePope]] 07:14, 17 July 2006 (UTC) Typo (possibly). '''page 36'''. Section 12.1.1 A survey of Haskell in Higher Education. On my screen it looks like there is an extra space after the number 28, in the sentence "Surprisingly, only 28 ..." Perhaps there is supposed to be a percent sign in there? Could be an artefact of the PDF viewer i'm using, but seems unlikely.<br />
<br />
[[User:BerniePope|BerniePope]] 07:21, 17 July 2006 (UTC) Typo. '''page 36'''. Section 12.1.1 A survey of Haskell in Higher Education. Bottom of second column. Backwards quotation marks at start of "The students who take the Haskell track ..."<br />
<br />
Typo on '''page 39''': Another example is that Linspire’s ''toold'' must handle legacy data formats. --[[User:NeilMitchell|Neil Mitchell]] 15:23, 14 July 2006 (UTC)<br />
<br />
[[User:BerniePope|BerniePope]] 13:06, 16 July 2006 (UTC) Overall. Capitalisation in headings seems to be inconsistent.<br />
<br />
== General comments ==<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Comment. '''page 7'''. Section 3.3, third paragraph. Rather than talk about "div" (are the first quote marks backwards?), perhaps you could say - "for example, Miranda's type system allows floating point values to be given to functions which are only defined on the integer subset of num, thus turning a static error into a dynamic one."<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Comment. '''page 10'''. Section 4.1, layout. It says "The rules are simple ...". I think this is a contentious issue. Recent discussions on the Haskell Prime mailing list [http://www.haskell.org//pipermail/haskell-prime/2006-March/000898.html] suggested a contrary view. How many Haskellers actually know the rules? Perhaps it would be more accurate to say that experience shows it is not hard to adopt a style of programming which stays within the rules.<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Comment. Footnote 2 on '''page 10''' says the Scheme authors took a more Draconian approach with respect to operators, though it doesn't actually say what that means. On the off chance that someone reading the paper doesn't know Scheme, it might be worth elaborating on that point.<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Comment. '''page 12'''. Section 4.4. Near the end of the section you give an example of "where" being attached to a declaration. I think the example function "f" is rather obscure, perhaps there is a better example? Maybe one from the Prelude? Also, there seems to be another point you could make here. Due to laziness we get some more freedom in the way that we write where clauses. For instance, the thing being defined in the where clause may only be well defined in a subset of the alternatives. But that doesn't matter because we will only evaluate the thing if and when it is needed, not before.<br />
<br />
[[User:BerniePope|BerniePope]] 15:42, 15 July 2006 (UTC) Comment. '''page 12'''. Section 4.5, list comprehensions. Perhaps it is worth noting the Haskell does not have the diagonalisation operator like Miranda. It may also be worth remarking on why this is so. Surely it was considered.<br />
<br />
[[User:BerniePope|BerniePope]] 16:05, 15 July 2006 (UTC) Comment. '''page 13'''. Section 5.3 Abstract types. It says that the type has one constructor. Is it really necessary to limit the type to just one constructor? Surely it is enough that the constructors of the type are not exported, regardless of how many there are?<br />
<br />
[[User:BerniePope|BerniePope]] 05:28, 16 July 2006 (UTC) Comment. '''page 14'''. Section 6.1, Type classes. Perhaps it should mention that '''eqInt''' is primitive equality on integers, maybe as a comment in the code.<br />
<br />
[[User:BerniePope|BerniePope]] 05:54, 16 July 2006 (UTC) Comment. '''page 15'''. Section 6.2 Monomorphism restriction. This marks one of the most unusual aspects of the language, especially in the Language Report. In particular, it is motivated by operational semantics --- sharing --- but the rest of the Report is largely silent on the issue. I think the Report says something to the effect of "programmers expect sharing to be preserved", but there is not much else in the Report to back this statement up. Perhaps you could tie this back to the discussion in Section 3.4 (Haskell has no formal semantics). Also, I think it would be reasonable to say "GHC provides a flag to suppress the restriction", without actually naming the flag.<br />
<br />
[[User:BerniePope|BerniePope]] 06:02, 16 July 2006 (UTC) Comment. '''page 15'''. Section 6.2 Higher kinded polymorphism. It says "Here, the type variable m has kind *->*". It seems like the reader is already supposed to know what a kind is at this point. Perhaps the section could provide a little introduction to the concept of kinds first. Another thing about kinds is that they are sort of shadowy figures that seem to lurk in the background of Haskell. For instance they have no syntactic counterpart in Haskell 98. It can be quite daunting for beginners when they get a kind error.<br />
<br />
[[User:BerniePope|BerniePope]] 07:30, 16 July 2006 (UTC) Comment. '''page 17'''. Section 6.6 Implicit parameters. Perhaps contrast this approach to a Reader monad?<br />
<br />
[[User:BerniePope|BerniePope]] 07:44, 16 July 2006 (UTC) Comment. '''page 18'''. Arrows. It doesn't really say what arrows are, except that they are like monads, but more general. Perhaps this could be elaborated, maybe with some mention of the intuition that arrows generalise things which are somehow composable? Perhaps an example of an arrow which cannot be done with a monad?<br />
<br />
[[User:BerniePope|BerniePope]] 08:14, 16 July 2006 (UTC) Comment. '''page 20'''. Section 7.2 Monads. It says that "Checking that the laws hold provides a reassuring sanity check when defining a new monad." Perhaps you could elaborate on exactly what we are checking, and subsequently reassured about. It says earlier that the laws show associativity and identity, but is there a more "programmer oriented" view of what this means? <br />
<br />
[[User:BerniePope|BerniePope]] 08:22, 16 July 2006 (UTC) Comment. '''page 20'''. Section 7.2 Monads. It says monads were helpful in structuring programs, including "the Haskell compiler itself". This sounds like there was a single Haskell compiler. Perhaps it should be "exisiting Haskell compilers"?<br />
<br />
[[User:BerniePope|BerniePope]] 08:22, 16 July 2006 (UTC) Comment. '''page 20'''. Section 7.2 Monads. One of the ongoing issues with monads is combining them together. Perhaps you could mention some of the attempts at doing this, such as monad transformers.<br />
<br />
[[User:BerniePope|BerniePope]] 13:04, 16 July 2006 (UTC) Comment. '''page 29'''. Section 10.3 Controlling Evaluation Order. The last paragraph suggests that we can wait until the program is written, then profile, then add seqs as necessary. While this is true, many programs are never really finished. Adding seq to code is one thing, but maintaining code with seq in it is another, perhaps more difficult problem. Also, you might be able to make a link here to the material on speculative evaluation, since that also solves some space/strictness issues.<br />
<br />
[[User:BerniePope|BerniePope]] 13:14, 16 July 2006 (UTC) Comment. '''page 29'''. Section 10.4 Debugging and tracing. It says that hbc and GHC provide trace. Hugs also has trace (perhaps nhc98 does as well?).<br />
<br />
[[User:BerniePope|BerniePope]] 04:59, 17 July 2006 (UTC) Comment. '''page 30'''. Section 10.4.2 Observational debugging. In the Hood library the type of observe is overloaded, like "observe :: Observeable a => String -> a -> a", which is both an interesting and useful application of type classes, and in some ways a limitation of hood, since it isn't polymorphic. I think it is important to point out the use of overloading here. Also, I think Hugs comes with a built-in polymorphic version, which of course isn't portable.<br />
<br />
[[User:Hoan|Hoan]] 12:45, 15 July 2006 (UTC) On '''page 33''' it says that Ruby on Rails is a continuation based framework. I think thats wrong. PS. Its a riveting read.<br />
<br />
[[User:BerniePope|BerniePope]] 07:57, 16 July 2006 (UTC) Overall. Names of people. I've noticed that sometimes people are referred to by their whole name, whilst others are referred to by just their family name. Perhaps there is an underlying method here, but it wasn't clear to me. Perhaps it is that the first reference gets a full name, and subsequent ones are just the family name? Is that always the case?<br />
<br />
[[User:Abayley|Abayley]] 07:37, 17 July 2006 (UTC) JHC gets a one-line mention - perhaps it deserves a little more? AFAICT, it was written by one person, as a student, who decided that the best way to learn Haskell was by writing a Haskell compiler. A commendable effort I think, and also a testament to the power of the language.</div>Abayleyhttps://wiki.haskell.org/index.php?title=Lazy_vs._non-strict&diff=4701Lazy vs. non-strict2006-07-12T13:01:09Z<p>Abayley: </p>
<hr />
<div>(this is a bit of a stub. Feel free to edit)<br />
<br />
Haskell is often described as a lazy language. However, the language specification simply states that Haskell is non-strict, which is not quite the same thing as lazy.<br />
<br />
(example/description of non-strict semantics; describe WHNF)<br />
<br />
Laziness is simply a common implementation technique for non-strict languages, but it is not the only possible technique. One major drawback with lazy implementations is that they are not generally amenable to parallelisation. This paper states that experiments indicate that little parallelism can be extracted from lazy programs:<br />
<br />
"The Impact of Laziness on Parallelism and the Limits of Strictness Analysis"<br />
(G. Tremblay G. R. Gao)<br />
http://citeseer.ist.psu.edu/tremblay95impact.html<br />
<br />
Lenient, or optimistic, evaluation is an implementation approach that lies somewhere between lazy and strict, and combines eager evaluation with non-strict semantics. This seems to be considered more promising for parallelisation.<br />
<br />
This paper implies (section 2.2.1) that lenient evaluation can handle circular data structures and recursive definitions, but cannot express infinite structures without explicit use of delays:<br />
<br />
"How Much Non-strictness do Lenient Programs Require?"<br />
(Klaus E. Schauser, Seth C. Goldstein)<br />
http://citeseer.ist.psu.edu/schauser95how.html<br />
<br />
Some experiments with non-lazy Haskell compilers have been attempted:<br />
http://www.haskell.org/haskellwiki/Research_papers/Runtime_systems#Optimistic_Evaluation</div>Abayleyhttps://wiki.haskell.org/index.php?title=Lazy_vs._non-strict&diff=4700Lazy vs. non-strict2006-07-12T13:00:18Z<p>Abayley: </p>
<hr />
<div>(this is a bit of a stub. Feel free to edit)<br />
<br />
Haskell is often described as a lazy language. However, the language specification simply states that Haskell is non-strict, which is not quite the same thing as lazy.<br />
<br />
(example/description of non-strict semantics; describe WHNF)<br />
<br />
Laziness is simply a common implementation technique for non-strict languages, but it is not the only possible technique. One major drawback with lazy implementations is that they are not generally amenable to parallelisation. This paper states that experiments indicate that little parallelism can be extracted from lazy programs:<br />
<br />
"The Impact of Laziness on Parallelism and the Limits of Strictness Analysis"<br />
(G. Tremblay G. R. Gao)<br />
http://citeseer.ist.psu.edu/tremblay95impact.html<br />
<br />
"Lenient" evaluation is an implementation approach that lies somewhere between lazy and strict, and combines eager evaluation with non-strict semantics. This seems to be considered more promising for parallelisation.<br />
<br />
This paper implies (section 2.2.1) that lenient evaluation can handle circular data structures and recursive definitions, but cannot express infinite structures without explicit use of delays:<br />
<br />
"How Much Non-strictness do Lenient Programs Require?"<br />
(Klaus E. Schauser, Seth C. Goldstein)<br />
http://citeseer.ist.psu.edu/schauser95how.html<br />
<br />
Some experiments with non-lazy Haskell compilers have been attempted:<br />
http://www.haskell.org/haskellwiki/Research_papers/Runtime_systems#Optimistic_Evaluation</div>Abayleyhttps://wiki.haskell.org/index.php?title=Performance/Overloading&diff=3974Performance/Overloading2006-05-04T08:16:26Z<p>Abayley: </p>
<hr />
<div>{{Performance infobox}}<br />
== Overloaded functions are not your friend ==<br />
<br />
Haskell's overloading (using type classes) is elegant, neat, etc., etc., but it is death to performance if left to linger in an inner loop. Each type class constraint on an overloaded function corresponds to an extra argument passed at runtime (called a ''dictionary'') (except in [[JHC]]!), and a reference to a class method is implemented by extracting a field from the dictionary. The presence of overloading can prevent many other optimisations, such as [[Performance:Strictness|Strictness]], from kicking in.<br />
<br />
How can you squash overloading?<br />
<br />
<b>Give explicit type signatures</b>: Signatures are the basic trick; putting them on exported, top-level functions is good software-engineering practice, anyway. (GHC Tip: using <tt>-fwarn-missing-signatures</tt> can help enforce good signature-practice).<br />
<br />
The automatic specialisation of overloaded functions (with <tt>-O</tt>) should take care of overloaded local and/or unexported functions.<br />
<br />
<b>Use <tt>SPECIALIZE</tt> pragmas</b>: Specialize the overloading on key functions in your program. (Supported by: [[GHC]], [[JHC]]).<br />
<br />
<b>Use a module export list</b>:<br />
If you omit the export list for the module, then everything in the module is exported. Also, any functions that lack type signatures will have the most general i.e. <i>polymorphic</i> types inferred for them. If those same functions are <i>only</i> used inside that module, then they are likely to be more polymorphic than necessary. Removing them from the module export list (whether explicit or implicit) will allow the compiler to specialise them to just the type(s) used in the module.</div>Abayley