Haskell Prime: Ticket Query
https://prime.haskell.org/query?status=!closed&type=task&desc=1&order=time
Haskell Language Report Working Groupen-USHaskell Primehttps://prime.haskell.org/chrome/site/HaskellLogo_2.jpg
https://prime.haskell.org/query?status=!closed&type=task&desc=1&order=time
Trac 1.0.9
https://prime.haskell.org/ticket/125
https://prime.haskell.org/ticket/125#125: Rename interact to iofilterThu, 02 Aug 2007 16:17:02 GMTguest<p>
The interact function in Prelude has an un-intuitive name.
I suggest using the name "iofilter" instead.
</p>
<ul><li>Alexander Rødseth (rodseth "@" gmail.com)
</li></ul>Resultshttps://prime.haskell.org/ticket/125#changelog
https://prime.haskell.org/ticket/122
https://prime.haskell.org/ticket/122#122: clarify literate script syntaxThu, 15 Mar 2007 01:13:57 GMTigloo@…<p>
The syntax for literate scripts needs to be clarified. See the thread
<a class="ext-link" href="http://www.haskell.org/pipermail/haskell-cafe/2007-March/023027.html"><span class="icon"></span>http://www.haskell.org/pipermail/haskell-cafe/2007-March/023027.html</a>
for more details.
</p>
<p>
The report should also give a reference unlitter. I'll attach (an untested) one from the above thread.
</p>
Resultshttps://prime.haskell.org/ticket/122#changelog
https://prime.haskell.org/ticket/121
https://prime.haskell.org/ticket/121#121: ExitCode consistencyWed, 14 Mar 2007 23:26:56 GMTigloo@…<p>
Haskell 98 says
</p>
<pre class="wiki">Computation system cmd returns the exit code produced when the operating system processes the command cmd.
</pre><p>
and
</p>
<pre class="wiki">The exact interpretation of code is operating-system dependent.
</pre><p>
However, on Unix systems <tt>system "exit 3" >>= print</tt> prints <tt>ExitFailure 3</tt> under ghc and hugs, but <tt>ExitFailure 768</tt> under nhc98, despite both being the same operating system.
</p>
<p>
It may not be possible to fix this within the boundaries of the report, but Something Must Be Done somewhere.
</p>
<p>
Additionally, the report says
</p>
<pre class="wiki">The value exitFailure is equal to exitWith (ExitFailure exitfail), where exitfail is implementation-dependent.
</pre><p>
while <tt>operating-system dependent</tt> seems better than <tt>implementation-dependent</tt>.
</p>
Resultshttps://prime.haskell.org/ticket/121#changelog
https://prime.haskell.org/ticket/119
https://prime.haskell.org/ticket/119#119: splitAt should be strict in its first argumentMon, 05 Mar 2007 22:55:37 GMTigloo@…<p>
The below is a slightly editted version of <a class="ext-link" href="http://hackage.haskell.org/trac/ghc/ticket/1182"><span class="icon"></span>http://hackage.haskell.org/trac/ghc/ticket/1182</a>
</p>
<hr />
<p>
The <a class="ext-link" href="http://haskell.org/onlinereport/standard-prelude.html"><span class="icon"></span>H98 report</a> defines <tt>splitAt</tt> by:
</p>
<pre class="wiki">splitAt :: Int -> [a] -> ([a],[a])
splitAt n xs = (take n xs, drop n xs)
</pre><p>
So we would expect:
</p>
<pre class="wiki">splitAt _|_ xs = (take _|_ xs, drop _|_ xs)
</pre><p>
however, both GHC and hugs have (different) implementations that are strict in 'n', that is:
</p>
<pre class="wiki">split _|_ xs = _|_
</pre><p>
These cases can be distinguished with the expression:
</p>
<pre class="wiki">case splitAt undefined [] of (_,_) -> ()
</pre><p>
We propose splitAt be changed to be strict in its first argument for Haskell'.
</p>
Resultshttps://prime.haskell.org/ticket/119#changelog
https://prime.haskell.org/ticket/118
https://prime.haskell.org/ticket/118#118: Remove libraries from the report (to the greatest extent possible)Mon, 05 Mar 2007 22:23:14 GMTigloo@…<p>
There is a tension between having the
ability to fix and evolve the libraries, and people wanting to write
books on how to use Haskell' (without having to define (+) and map etc
themselves!).
</p>
<p>
We've been lucky thus far that having the hierarchial libraries
completely disjoint with the report has meant that we have been able add
to and alter things even in the base package without breaking anything
assuming Haskell 98. We haven't had to worry about clashing with a user's
<tt>Data.Function</tt> module as the Haskell 98 namespace is flat, nor worry whether
adding an <tt>on</tt> function will cause ambiguous-import errors in someone's
Haskell 98 program.
</p>
<p>
We still get the occasional person in #haskell asking why they can't
find the <tt>fromInt</tt> their book talks about, and I think that was probably
published in the 90s?
</p>
<p>
This proposal is that books should be about
</p>
<pre class="wiki">Haskell', base 3.0.* and mtl 2.1.*
</pre><p>
and Haskell'
should say pretty much nothing about libraries. This gives book writers
the ability to target something (and even if newer library versions come out,
the old ones will still be available; old branches can even be maintained so they
stay working with newer implementations if necessary) while still letting us
remain agile.
</p>
<p>
The report will probably need to continue to use things like <tt>head</tt> in
non-normative sections such as examples.
</p>
<p>
There will probably also need to be a package defined by Haskell' that includes things like seq and the derivable classes. It might also define IO primitives etc,
but these might be better left unspecified, with the (portable) <tt>io</tt> package depending on <tt>$impl-io</tt> (e.g. <tt>ghc-io</tt>) which defines suitable primitives for the implementation.
</p>
Resultshttps://prime.haskell.org/ticket/118#changelog
https://prime.haskell.org/ticket/116
https://prime.haskell.org/ticket/116#116: Read Char instance, for [Char], and ['a', 'b'] syntaxSun, 04 Mar 2007 14:30:30 GMTigloo@…<p>
Haskell 98, in section 10.4, states:
</p>
<pre class="wiki">readsPrec will parse any valid representation of the standard types apart
from strings, for which only quoted strings are accepted
</pre><p>
hugs follows this:
</p>
<pre class="wiki">Hugs.Base> read "['a', 'b']" :: String
"
Program error: Prelude.read: no parse
</pre><p>
while GHC ignores it:
</p>
<pre class="wiki">Prelude> read "['a', 'b']" :: String
"ab"
</pre><p>
The GHC libraries source shows that this is a wilful variation from H98:
</p>
<pre class="wiki"> readListPrec =
parens
( do L.String s <- lexP -- Looks for "foo"
return s
+++
readListPrecDefault -- Looks for ['f','o','o']
) -- (more generous than H98 spec)
</pre><p>
I do not see the point of this inconsistency, so I believe we should consider changing it for Haskell'.
</p>
Resultshttps://prime.haskell.org/ticket/116#changelog
https://prime.haskell.org/ticket/115
https://prime.haskell.org/ticket/115#115: Complex arithmetic misbehaves in boundary casesTue, 02 Jan 2007 18:08:19 GMTguest<p>
Consider complex multiplication. If we have a number x+iy and multiply this number by i we get -y+ix.
Let us try the same thing in Haskell with IEEE floating point:
let inf = 1.0/0.0
</p>
<blockquote>
<p>
a = 1 :+ inf
i = 0 :+ 1
</p>
</blockquote>
<p>
in a * i
This comes out as (-Infinity) :+ NaN when it should have been (-Infinity) :+ 1.0.
It is not just a made up problem, see, e.g., <a class="ext-link" href="http://www.cs.berkeley.edu/~wkahan/Curmudge.pdf"><span class="icon"></span>http://www.cs.berkeley.edu/~wkahan/Curmudge.pdf</a>
</p>
<p>
We should address this problem. I have not yet determined if testing for
a real part of 0 in multiplication (and division) is sufficent, but I think
it is. I will be back with more information on the fix.
</p>
<blockquote>
<p>
— Lennart
</p>
</blockquote>
Resultshttps://prime.haskell.org/ticket/115#changelog
https://prime.haskell.org/ticket/112
https://prime.haskell.org/ticket/112#112: Break unnecessary dependencies between Haskell numeric classesWed, 20 Sep 2006 19:51:39 GMTguest<p>
Motivation:
</p>
<p>
The Haskell numeric classes contain some interdependencies that look rather odd to a mathematician. For example, why do you have to be Show in order to be Num, and why do you have to be Enum in order to be Integral. These dependencies are not justified by mathematical considerations, and make it hard to represent some mathematical concepts in Haskell.
</p>
<p>
For example, consider the Gaussian integers - numbers of the form a+bi, where a and b are integers, and i is the square root of -1. (Complex Integer, if you like.) There is a division with remainder algorithm for the Gaussian integers, so that we would like to declare them as an instance of Integral, and define the quotRem function. However, to do this we would have to declare them as an instance of Enum - and this makes no sense - there is no natural way to define the Enum functions on the Gaussian integers.
</p>
<p>
For similar reasons, the dependency of Integral on Real is suspect - there is no natural way to define toRational on the Gaussian integers.
</p>
<p>
The dependency of <a class="missing wiki">RealFrac?</a> on Fractional is also unnecessary - what have floor, ceiling etc got to do with recip?
</p>
<p>
Note that breaking these dependencies will not break any existing code. At present, if I declare a type T to be a Num instance, I must also declare it to be an Eq instance and a Show instance. If the dependency is broken, that is, if
</p>
<p>
class (Eq a, Show a) ⇒ Num a
</p>
<p>
is replaced by
</p>
<p>
class Num a
</p>
<p>
then existing code will still work.
</p>
<p>
What will have changed is that it will now be possible to declare a type T to be a Num instance without also declaring it to be an Eq and a Show instance.
</p>
<p>
Proposal:
</p>
<p>
Conservative version:
</p>
<p>
Replace the existing Prelude class declarations with:
</p>
<ol><li>class Eq a ⇒ Num a — remove dependency on Show
</li></ol><ol start="2"><li>class Num a ⇒ Integral a — replace dependency on Real, Enum by dependency on Num
</li></ol><ol start="3"><li>class Real a ⇒ <a class="missing wiki">RealFrac?</a> a — remove dependency on Fractional
</li></ol><p>
Radical version:
</p>
<p>
In addition to the above:
</p>
<ol start="4"><li>Split abs and signum out from Num into a new
</li></ol><p>
class Num a ⇒ Quantity a
</p>
<p>
(There are plenty of objects in mathematics for which the arithmetical operations +,-,* make sense, but the size and direction operations abs and signum do not - for example polynomials, matrices.)
</p>
<ol start="5"><li>Amalgamate classes Real and <a class="missing wiki">RealFrac?</a> - Real no longer has any purpose as a distinct class. The new class should probably be called Real.
</li></ol><p>
See also: <a class="wiki" href="https://prime.haskell.org/wiki/NumericClasses">NumericClasses</a>.
</p>
Resultshttps://prime.haskell.org/ticket/112#changelog
https://prime.haskell.org/ticket/111
https://prime.haskell.org/ticket/111#111: remove local fixity declarationsMon, 18 Sep 2006 00:34:14 GMTDoaitse Swierstra<p>
On page 38 the language definition allows local fixity declarations. Since no-one seems to be using these, not to be aware of the possibility to do so, I propose to remove them. The necessity to inspect every block to see whether there are fixity declarations, and the necessity to parse all expressions twice is cumbersome.
</p>
Resultshttps://prime.haskell.org/ticket/111#changelog
https://prime.haskell.org/ticket/110
https://prime.haskell.org/ticket/110#110: Generalize types of IO actionsFri, 21 Apr 2006 18:33:30 GMTguest<p>
One nice way to structure programs is to use monad transformers on top of IO. For example, one common technique is to use StateT or ReaderT to propagate custom state through IO code. This technique has two problems
</p>
<p>
1) It requires one to use 'liftIO' rather a lot, which is mildly irritating
</p>
<p>
2) It makes it very difficult to use higher-order IO combinators, such as try or bracket, which is highly irritating
</p>
<p>
This proposal involves generalizing the types of standard IO functions to make this use-case easier.
</p>
<p>
Conservative proposal:
</p>
<p>
Generalize higher order IO combinators to take a MonadIO context. For example, try and catch would then have types
</p>
<pre class="wiki">try :: MonadIO m => m a -> m (Either Exception a)
catch :: MonadIO m => m a -> (Exception -> m a) - > m a
</pre><p>
This allows one to use custom monads built on IO and still do correct exception handling, etc. without having to do lots of nasty monad unwrapping/rewrapping.
</p>
<p>
NOTE: This is not possible to implement. there is no way to 'rewind' a monad
in a generic way in order to implement try or catch. - <a class="missing wiki">JohnMeacham?</a>
</p>
<p>
NOTE: An alternative is to use a different version of Control.Exception that defines a typeclass as follows:
</p>
<pre class="wiki">class MonadIO m => MonadException m where
catch :: m a -> (Exception -> m a) -> m a
block, unblock :: m a -> m a
</pre><p>
This can be implemented for the common monad transformers, and all the other exception functions can be implemented just using the methods in the above typeclass, or using liftIO with the existing functions. A full implementation (not fully tested though) is attached. — Brian Hulley
</p>
<p>
NOTE: Even though not all uses of IO can be eliminated (eg when defining callback functions to use with FFI), the importance of having an Exception module which is not tied to concrete <tt>IO</tt> is that it would allow library writers which require <tt>block</tt>, <tt>bracket</tt> etc to use the more general <tt>MonadException</tt> in place of <tt>IO</tt>. If library writers do not do this, users of the library, which may be other libraries etc, are also tied down to concrete <tt>IO</tt>, so the longer we leave it, the more difficult it will be to "unconcretise" the code base. — Brian Hulley
</p>
<p>
More radical proposal:
</p>
<p>
Generalize the types of all standard library IO routines to take MonadIO contexts. For example,
</p>
<p>
putChar :: MonadIO m ⇒ Char → m ()
</p>
<p>
getChar :: MonadIO m ⇒ m Char
</p>
<p>
These could easily be defined in terms of lower level IO primitives:
</p>
<p>
putCharIO :: Char → IO ()
</p>
<p>
putCharIO = …
</p>
<p>
putChar c = liftIO (putChar c)
</p>
<p>
Now you can eliminate a bunch of noisy calls to liftIO in client code.
</p>
<p>
NOTE: This should be quite trivial to implement for all functions which just use <tt>IO</tt> in the return value. When <tt>IO</tt> is used in other positions it is unlikely to be possible to implement except by replacing the other occurrence of <tt>IO</tt> by <tt>MonadIOU</tt> defined by:
</p>
<pre class="wiki"> class MonadIO m => MonadIOU m where
getUnliftIO :: m (m a -> IO a)
</pre><p>
Unfortunately only a few of the monad transformers support this operation (eg <tt>ReaderT</tt> ) but at least it's better than nothing. An alternative would be to define special typeclasses for related sets of operations if this would allow more monad transformers to be supported by the particular operations, or to add first-order api functions which a library user could use to build a specialised version of the higher order function for a specific monad. — Brian Hulley
</p>
Resultshttps://prime.haskell.org/ticket/110#changelog
https://prime.haskell.org/ticket/109
https://prime.haskell.org/ticket/109#109: split Enum into two typeclassesSun, 09 Apr 2006 23:26:41 GMTguest<p>
The current uses of Enum are somewhat confusing — this is partially because of the name, but partially because two seperate interfaces are glued together. One provides Enumeration of all possible values and conversion to integers for binary storage, and the other provides sequences of values (usually arithmetic) (which [a..b], etc desugar to).
</p>
<pre class="wiki">class Enum a where
succ, pred :: a -> a
toEnum :: Int -> a
fromEnum :: a -> Int
instance Enum Integer
instance Enum Int
instance Enum Bool
instance Enum Ordering
instance Enum Word...
</pre><pre class="wiki">class ArithmeticSequence a where
stepFrom :: a -> [a] -- [n..]
stepFromThen :: a -> a -> [a] -- [n, n'..]
stepFromTo :: a -> a -> [a] -- [n..m]
stepFromThenTo :: a -> a -> a -> [a] -- [n,n'..m]
instance ArithmeticSequence Integer
instance ArithmeticSequence Int
instance ArithmeticSequence Bool
instance ArithmeticSequence Ordering
instance ArithmeticSequence Float
instance ArithmeticSequence Double
instance ArithmeticSequence Rational
instance ArithmeticSequence Word...
...
</pre><p>
Steppable may be a preferrable name.
</p>
<p>
pros:
</p>
<ul><li>Clearly divides two seperate uses, while keeping functionality.
</li><li>Can re-introduce relationship between Ix and Enum?
</li></ul><p>
cons:
</p>
<ul><li>Yet another typeclass.
</li><li>Slightly misleading name, as non-arithmetic structures _should_ be supported. Also a bit long.
</li><li>Automatically supporting such isn't trivial if they're not in Enum, though.
</li></ul>Resultshttps://prime.haskell.org/ticket/109#changelog
https://prime.haskell.org/ticket/108
https://prime.haskell.org/ticket/108#108: make toEnum and fromEnum take and return IntegersSun, 09 Apr 2006 23:07:00 GMTguest<p>
Change the signature of toEnum and fromEnum in the Enum a typeclass to
</p>
<pre class="wiki"> toEnum :: Integer -> a
fromEnum :: a -> Integer
</pre><p>
(they currently use Int)
</p>
<p>
It's possible, for example, to have Enumeratable types that are larger than Int
</p>
<p>
pros: No overflow possibilities
</p>
<p>
cons: efficiency
</p>
Resultshttps://prime.haskell.org/ticket/108#changelog
https://prime.haskell.org/ticket/106
https://prime.haskell.org/ticket/106#106: Adding deepSeq/strict to Haskell' beside seq.Thu, 30 Mar 2006 22:51:03 GMTandy@…<p>
We are considering deepSeq for Haskell'.
See <a class="wiki" href="https://prime.haskell.org/wiki/deep_seq">deep_seq</a> for more details.
</p>
Resultshttps://prime.haskell.org/ticket/106#changelog
https://prime.haskell.org/ticket/105
https://prime.haskell.org/ticket/105#105: Disambiguate MonadPlusThu, 30 Mar 2006 05:49:17 GMTashley@…<p>
Reform the <tt>MonadPlus</tt> class along these lines:
</p>
<pre class="wiki">class Monad m => MonadZero m where
mzero :: m a
class MonadZero m => MonadPlus m where
mplus :: m a -> m a -> m a
class MonadZero m => MonadOr m where
morelse :: m a -> m a -> m a
</pre><p>
<a class="ext-link" href="http://haskell.org/haskellwiki/MonadPlus_reform_proposal"><span class="icon"></span>http://haskell.org/haskellwiki/MonadPlus_reform_proposal</a>
</p>
Resultshttps://prime.haskell.org/ticket/105#changelog
https://prime.haskell.org/ticket/104
https://prime.haskell.org/ticket/104#104: Add Time LibraryThu, 30 Mar 2006 05:38:12 GMTashley@…<ol><li>Add Data.Fixed module to the base package.
<a class="ext-link" href="http://semantic.org/TimeLib/doc/html/Data-Fixed.html"><span class="icon"></span>http://semantic.org/TimeLib/doc/html/Data-Fixed.html</a> <br />
<a class="ext-link" href="http://darcs.haskell.org/packages/time/fixed/Data/Fixed.hs"><span class="icon"></span>http://darcs.haskell.org/packages/time/fixed/Data/Fixed.hs</a>
</li></ol><ol start="2"><li>Add package "time" to the standard libraries.
<a class="ext-link" href="http://semantic.org/TimeLib/doc/html/"><span class="icon"></span>http://semantic.org/TimeLib/doc/html/</a> <br />
<a class="ext-link" href="http://darcs.haskell.org/packages/time/"><span class="icon"></span>http://darcs.haskell.org/packages/time/</a>
</li></ol><ol start="3"><li>Deprecate System.Time.
<a class="ext-link" href="http://haskell.org/ghc/dist/current/docs/libraries/base/System-Time.html"><span class="icon"></span>http://haskell.org/ghc/dist/current/docs/libraries/base/System-Time.html</a>
</li></ol>Resultshttps://prime.haskell.org/ticket/104#changelog
https://prime.haskell.org/ticket/103
https://prime.haskell.org/ticket/103#103: Make pattern bindings monomorphicWed, 29 Mar 2006 07:32:41 GMTsimonpj@…<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/MonomorphicPatternBindings">MonomorphicPatternBindings</a>
</p>
Resultshttps://prime.haskell.org/ticket/103#changelog
https://prime.haskell.org/ticket/102
https://prime.haskell.org/ticket/102#102: add Liberal Type SynonymsTue, 28 Mar 2006 11:14:57 GMTsimonmar@…<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/LiberalTypeSynonyms">LiberalTypeSynonyms</a>
</p>
Resultshttps://prime.haskell.org/ticket/102#changelog
https://prime.haskell.org/ticket/101
https://prime.haskell.org/ticket/101#101: Class AliasesSun, 26 Mar 2006 00:43:25 GMTguest<p>
See <a class="ext-link" href="http://repetae.net/john/recent/out/classalias.html"><span class="icon"></span>http://repetae.net/john/recent/out/classalias.html</a>
</p>
<pre class="wiki">class alias Num a = (Additive a, AdditiveNegation a,
Multiplicative a, FromInteger a) where
one = fromInteger 1
zero = fromInteger 0
negate x = zero - x
</pre>Resultshttps://prime.haskell.org/ticket/101#changelog
https://prime.haskell.org/ticket/100
https://prime.haskell.org/ticket/100#100: Replace named fields with an extensible record systemThu, 23 Mar 2006 16:07:05 GMTmalcolm.wallace@…<p>
This proposal is to remove the existing named field system, and replace it with an extensible record system. Candidates for this new system are open for discussion, but Daan Leijen has several interesting variations which might be a good starting point.
</p>
Resultshttps://prime.haskell.org/ticket/100#changelog
https://prime.haskell.org/ticket/99
https://prime.haskell.org/ticket/99#99: Move existing named field (record) system to an addendum.Thu, 23 Mar 2006 16:03:58 GMTmalcolm.wallace@…<p>
This is a proposal to explicitly reject any new record system for Haskell-prime, but to keep the current named field system, possibly with some minor tweaking. However, the named field system would be moved to an addendum, which a future committee may see fit to discard in favour of some other record system.
</p>
<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/ExistingRecords">ExistingRecords</a>.
</p>
Resultshttps://prime.haskell.org/ticket/99#changelog
https://prime.haskell.org/ticket/98
https://prime.haskell.org/ticket/98#98: Restricted Data Types NowWed, 22 Mar 2006 00:12:00 GMTguest<p>
We should adopt Oleg's "Restricted Data Types Now" approach for simpler cases, like Functor, that don't involve creating new type classes.
</p>
<pre class="wiki">class Functor f a b where
fmap :: (a -> b) -> f a -> f b
instance (Ord a, Ord b) => Functor Data.Set.Set a b where
...
</pre>Resultshttps://prime.haskell.org/ticket/98#changelog
https://prime.haskell.org/ticket/97
https://prime.haskell.org/ticket/97#97: Collection library interfaceWed, 22 Mar 2006 00:04:48 GMTguest<p>
We should make a collection library interface, using whatever new features end up in Haskell'. See: <a class="ext-link" href="http://hackage.haskell.org/trac/ghc/wiki/CollectionClassFramework"><span class="icon"></span>http://hackage.haskell.org/trac/ghc/wiki/CollectionClassFramework</a>
</p>
Resultshttps://prime.haskell.org/ticket/97#changelog
https://prime.haskell.org/ticket/95
https://prime.haskell.org/ticket/95#95: improve module interfacesWed, 22 Feb 2006 15:45:28 GMTmalcolm.wallace@…<p>
Proposal:
</p>
<p>
adopt <a class="wiki" href="https://prime.haskell.org/wiki/TagExportsWithNamespace">TagExportsWithNamespace</a> and <a class="wiki" href="https://prime.haskell.org/wiki/PermitSignaturesInExports">PermitSignaturesInExports</a>
</p>
<p>
I don't understand the <a class="missing wiki">NameSpace?</a> proposal: neither what it is trying to accomplish, not what it achieves. Could you be a little more explicit? Thanks, John
</p>
Resultshttps://prime.haskell.org/ticket/95#changelog
https://prime.haskell.org/ticket/94
https://prime.haskell.org/ticket/94#94: Syntax for specifing language extensionsThu, 16 Feb 2006 23:44:15 GMTpatrykz@…<p>
One of the original Haskell goals was to define a language for experimentation
with functional language features. This will not change with Haskell' - we
already know that at least one feature that is in high demand (FDs) is not ready
for inclusion in Haskell'.
</p>
<p>
However, Haskell still does not provide any internal mechanism to facilitate
language experimentation. In particular, the language does not provide
a mechanism for keeping track of the languaged extensions in used by
a particular piece of code.
</p>
<p>
To make things worse, many (most?) extension require lexical and/or
syntactic changes to the language. Some extensions in the past proved
to be incompatible, and not all compilers implement all extensions.
</p>
<p>
So, looking at a particular piece of code, how do we know which compiler
it can be compiled with, and which command-line flags do we pass to
which compiler? The answer is, simply, we don't.
</p>
<p>
Currently, we do this by introducing ugly GHC-specific pragmas, comments
in the documentation, and a plethora of similar half-measures.
</p>
<p>
I would like to propose a language feature to address this concern
once and for all. I know that a similar proposal has been circulated on the
Haskell mailing list in the past, but to the best of my knowledge, none of
the current tickets addresses this problem.
</p>
<h2 id="TheProposal">The Proposal</h2>
<p>
Add explicit syntax for documenting language extensions required to
compile a module.
</p>
<h2 id="TheProblem">The Problem</h2>
<ul><li>Current language does not provide a uniform extension mechanism.
</li><li>Pragmas (as currently used in GHC) are NOT suitable for this. Specifically,
by their design they are COMMENTS, and therefore should have no impact on
the language semantics. Unrecognized pragmas should be ignorable without
warnings, while, currently, if you omit the GHC options pragma for a module
that requires some syntactic extension, you will receive thousands of lexical
and syntactic errors completely unrelated to your extension.
</li><li>I <em>strongly</em> believe that compiler pragmas should ONLY be used for
extensions (such as <tt>INLINE</tt>, various <tt>SPECIALIZE</tt>, etc.) that have no impact
on the program semantics.
</li></ul><h2 id="TheSolution">The Solution</h2>
<p>
Add an <tt>extension</tt> clause to the language.
</p>
<p>
To avoid introduction of a new keyword, I propose to use the following syntax:
</p>
<pre class="wiki"> module -> [extensions;] "module" modid [exports] "where" body
| body
extensions -> extension_1 ; ... ; extension_n
extension -> "import" "extension" varid [extparam_1 ... extparam_n]
extparam -> varid | conid | literal
</pre><p>
A module using some GHC woo-hah extension would look like:
</p>
<pre class="wiki"> import extension GHC "woo-hah!"
module Foo ...
</pre><p>
Or, if an extension is common enough:
</p>
<pre class="wiki"> import extension fundeps
module Foo ...
</pre><p>
This is a very conservative syntax. It does not support grouping, aliasing and
renaming of extensions (as previously circulated on the haskell mailing list)
which I personally believe would be very a bad idea. I want to be able to look
at a piece of Haskell code and tell immediately which extensions it uses,
without being forced to browse through the included modules, etc. Further,
the parsers and lexers must be able to tell where the list of extensions finishes
and the module code (which uses these extensions) starts. The "module" keyword
is a natural candidate for that.
</p>
<p>
Extensions would NOT be exported by a module that uses that
extension, but would have to be specified separately by each module that uses the
features provided by that extension. For example, one often hides uses of unboxed
types, functional dependencies, etc, behind a curtain of abstract data types, and
such data type implemented using non-standard features can be happily used within
standard-conforming Haskell programs. On the other hand, if an extension is visible in
an interface exported by a module, it has to be named explicitly (with <tt>import extension</tt>
clauses) by any module importing that interface.
</p>
<p>
Extensions could be parametized, since I can readily imagine extensions that
would require such a thing. I would also recommend in the standard
that every compiler groups its own extensions under a common name (for
example, GHC, HUGS, JHC, NHC, etc.) until they are in sufficiently common use to be
standardized independently (such as fundeps), at which stage there should
probably be a corresponding addendum to the standard for that extension.
</p>
<p>
Specifying extensions before the <tt>module</tt> keyword ensures that the
lexer and parser can find them before parsing of the actual module. I
recommend that bare modules without the <tt>module</tt> keyword cannot specify any
extensions, and therefore must be written in pure Haskell'.
</p>
<p>
The standard itself should not define any extensions and state that
the standard grammar and semantics describes the base language in
absence of any <tt>import extension</tt> clauses.
</p>
<p>
Each extension, including FFI, should be described in a separate addendum.
Once an extension has been fully defined and tested in production code, it
may be <em>blessed</em> by including it in the list of addenda to the standard, at
which case its name will change from compiler-specific (eg. <tt>GHC woohoo</tt>)
to standard (eg. <tt>woohoo</tt>.)
</p>
<h3 id="Pros">Pros</h3>
<ul><li>Addresses a pending language design goal.
</li><li>Useful for automatic documentation tools such as Haddock, which could
even generate a hyperlink from an extension name to the relevant
addendum when available.
</li><li>Simple to implement.
</li><li>Neat syntax.
</li><li>Backwards-compatible (introduces no keyword polution.)
</li><li>Makes all information required to compile a program available directly
in the source code, rather than in ad-hoc places such as command-line,
Cabal package descriptions, documentation, comments, pragmas and what-not.
</li><li>Returns all comments (including pragmas) to their original code as
semantically-neutral annotations on the source program.
</li></ul><p>
</p>
<h3 id="Cons">Cons</h3>
<ul><li>Some implementation hassles. The compiler must use either a predicated
parser and lexer (I believe most do already) or else parse the module
until it finds the "module" keyword collecting the extension clauses,
and then parse the actual module using an appropriate parser and
lexer chosen according to the specified extensions.
</li></ul>Resultshttps://prime.haskell.org/ticket/94#changelog
https://prime.haskell.org/ticket/91
https://prime.haskell.org/ticket/91#91: Unify various annotation proposalsSat, 11 Feb 2006 01:39:24 GMTijones<p>
Is an elegant, more specific proposal possible that will solve these problems?
</p>
<ol><li>Waldmann proposed <a class="new ticket" href="https://prime.haskell.org/ticket/88" title="enhancement: unified and extensible annotations (new)">unified and extensible annotations</a>.
</li><li>Zadarnowski proposed <a class="ext-link" href="http://www.haskell.org//pipermail/haskell-prime/2006-February/000335.html"><span class="icon"></span>specifying language extensions</a>.
</li><li>There are some <a class="wiki" href="https://prime.haskell.org/wiki/NewPragmas">NewPragmas</a> which are <a class="new ticket" href="https://prime.haskell.org/ticket/51" title="enhancement: add new pragmas (new)">under consideration</a>. These might be eliminated by annotations.
</li></ol>Resultshttps://prime.haskell.org/ticket/91#changelog
https://prime.haskell.org/ticket/90
https://prime.haskell.org/ticket/90#90: solve the MultiParamTypeClassDilemmaSat, 11 Feb 2006 00:41:36 GMTijones<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/MultiParamTypeClassesDilemma">a description of the dilemma</a>. This is not a proposal, but is related to a number of proposals that must be considered together:
</p>
<ol><li><a class="wiki" href="https://prime.haskell.org/wiki/MultiParamTypeClasses">MultiParamTypeClasses</a>
</li><li><a class="wiki" href="https://prime.haskell.org/wiki/FunctionalDependencies">FunctionalDependencies</a>
</li><li><a class="wiki" href="https://prime.haskell.org/wiki/AssociatedTypes">AssociatedTypes</a>
</li></ol>Resultshttps://prime.haskell.org/ticket/90#changelog
https://prime.haskell.org/ticket/87
https://prime.haskell.org/ticket/87#87: add dictionary definitions to wikiFri, 03 Feb 2006 18:51:36 GMTflippa<p>
Add some definitions of technical terms users of this wiki may not be familiar with.
</p>
<p>
An example might be Predicativity (or equally, Impredicativity) in the context of type systems. A starter definition for those might be:
</p>
<p>
"When talking about type systems, and ignoring historical context:
</p>
<ul><li>Predicative: type variables only instantiate to monotypes
</li><li>Impredicative: type variables may be instantiated to any type"
</li></ul>Resultshttps://prime.haskell.org/ticket/87#changelog
https://prime.haskell.org/ticket/86
https://prime.haskell.org/ticket/86#86: add PartialTypeAnnotations?Thu, 02 Feb 2006 18:03:20 GMTflippa<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/PartialTypeAnnotations">PartialTypeAnnotations</a>.
</p>
Resultshttps://prime.haskell.org/ticket/86#changelog
https://prime.haskell.org/ticket/78
https://prime.haskell.org/ticket/78#78: Add infix type constructorsWed, 25 Jan 2006 13:29:21 GMTsimonmar@…<p>
see <a class="wiki" href="https://prime.haskell.org/wiki/InfixTypeConstructors">InfixTypeConstructors</a>.
</p>
Resultshttps://prime.haskell.org/ticket/78#changelog
https://prime.haskell.org/ticket/66
https://prime.haskell.org/ticket/66#66: make sure removal candidates are added as proposalsSat, 17 Dec 2005 00:50:44 GMTijones<p>
see <a class="wiki" href="https://prime.haskell.org/wiki/RemovalCandidates">RemovalCandidates</a>.
</p>
Resultshttps://prime.haskell.org/ticket/66#changelog
https://prime.haskell.org/ticket/58
https://prime.haskell.org/ticket/58#58: prelude re-organisation proposalSat, 17 Dec 2005 00:35:08 GMTijones<p>
see the concrete proposal at the bottom of this page: <a class="wiki" href="https://prime.haskell.org/wiki/Prelude">Prelude</a>.
</p>
<p>
See also <a class="new ticket" href="https://prime.haskell.org/ticket/124" title="modification: Do not import the Prelude by default for proper modules (new)">#124</a>.
</p>
Resultshttps://prime.haskell.org/ticket/58#changelog
https://prime.haskell.org/ticket/48
https://prime.haskell.org/ticket/48#48: clarify module system proposalsFri, 16 Dec 2005 23:52:02 GMTijones<p>
see <a class="wiki" href="https://prime.haskell.org/wiki/ModuleSystem">ModuleSystem</a>. Lots of stuff here, not necessarily clear proposals.
</p>
Resultshttps://prime.haskell.org/ticket/48#changelog
https://prime.haskell.org/ticket/47
https://prime.haskell.org/ticket/47#47: make sure all minor library changes are added as proposals?Fri, 16 Dec 2005 23:49:57 GMTijones<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/MinorLibraryChanges">MinorLibraryChanges</a>. This might be too much to track w/ ticket system?
</p>
Resultshttps://prime.haskell.org/ticket/47#changelog
https://prime.haskell.org/ticket/45
https://prime.haskell.org/ticket/45#45: double check that all MinorFixes are listed as proposals, and minorFri, 16 Dec 2005 23:48:41 GMTijones<p>
see <a class="wiki" href="https://prime.haskell.org/wiki/MinorFixes">MinorFixes</a>.
</p>
Resultshttps://prime.haskell.org/ticket/45#changelog
https://prime.haskell.org/ticket/27
https://prime.haskell.org/ticket/27#27: create proposal(s): tweak the existing records systemFri, 16 Dec 2005 23:01:21 GMTijones<p>
See <a class="wiki" href="https://prime.haskell.org/wiki/ExistingRecords">ExistingRecords</a>. Create specific proposals for this.
</p>
<p>
Here's a proposal from David Roundy (found on Haskell mailing list):
</p>
<p>
I'd like to humbly submit a conservative proposal for changes to the
records mechanism for Haskell '06. The plan for Haskell '06 (to the
extent
that there is one) is to make it a conservative modification of Haskell
98, which is a good idea. As such, I don't think features should be
added
to the language that haven't been both implemented and tested, and the
problem with the whole records problem is that pretty much every
proposed
improvement is *not* backwards-compatible with Haskell 98, and therefore
hasn't been either implemented or tried out.
</p>
<p>
My idea is to make a small change, which will also not be
backwards-compatible with Haskell 98, but will *almost* be, and will be
hopefully forward-compatible with most complete solutions. At a
minimum,
the proposed change will allow the prototyping of real solutions as a
non-invasive preprocessor a la DrIFT.
</p>
<p>
My proposal is simply to remove the automatic declaration of accessor
functions. In Haskell 98,
</p>
<pre class="wiki">data FooBar = Foo { foo :: Int } | FooBar = { foo :: Int, bar :: Int }
</pre><p>
desugars to something like
</p>
<pre class="wiki">data FooBar = Foo Int | FooBar Int Int
foo :: FooBar -> Int
foo (Foo f) = f
foo (FooBar f _) = f
bar :: FooBar -> Int
bar (Foo _) = error "bad Foo"
bar (FooBar _ b) = b
</pre><p>
plus additional sugar for constructors and pattern matching. I would
leave
the sugar for constructors and pattern matching in place, but remove the
automatic declaration of functions "foo" and "bar".
</p>
<p>
This change "solves" the problem that different records in a single
namespace cannot share field names in a simple manner. In order to
allow
the writing of records code with is both valid Haskell 98 and valid
Haskell
'06, I'd suggest a pragma that causes the Haskell '06 compiler to
generate
the accessor functions. It's a bit ugly, but seems best to me. An
alternative would be a standard TH function to do the same, but I don't
know if TH is going to be included in Haskell '06.
</p>
<p>
This change may look like a step backwards (which it is), but I think
that
it would allow significant steps forward.
</p>
<p>
One open question (in my mind) would be whether we'd allow
</p>
<pre class="wiki">data Foo = FooInt { foo :: Int } | FooChar { foo :: Char }
</pre><p>
In the "new" system, there's no reason this need be illegal.
</p>
Resultshttps://prime.haskell.org/ticket/27#changelog
https://prime.haskell.org/ticket/22
https://prime.haskell.org/ticket/22#22: create DerivedInstances proposalFri, 16 Dec 2005 22:49:37 GMTijones<p>
There are a number of issues relating to <a class="wiki" href="https://prime.haskell.org/wiki/DerivedInstances">DerivedInstances</a>. Create concrete proposal(s) for them. See also <a class="wiki" href="https://prime.haskell.org/wiki/NewtypeDeriving">NewtypeDeriving</a>.
</p>
Resultshttps://prime.haskell.org/ticket/22#changelog
https://prime.haskell.org/ticket/21
https://prime.haskell.org/ticket/21#21: improve defaulting rulesFri, 16 Dec 2005 22:48:26 GMTijones<p>
see proposal on this page: <a class="wiki" href="https://prime.haskell.org/wiki/Defaulting">Defaulting</a>.
</p>
Resultshttps://prime.haskell.org/ticket/21#changelog
https://prime.haskell.org/ticket/16
https://prime.haskell.org/ticket/16#16: Create unicode proposalFri, 16 Dec 2005 22:35:00 GMTijones<p>
Create a proposal based on unicode.
</p>
<p>
Current proposals:
</p>
<ul><li><a class="wiki" href="https://prime.haskell.org/wiki/SourceEncodingDetection">SourceEncodingDetection</a>
</li></ul><p>
See:
</p>
<ul><li><a class="wiki" href="https://prime.haskell.org/wiki/UnicodeInHaskellSource">UnicodeInHaskellSource</a>
</li><li><a class="wiki" href="https://prime.haskell.org/wiki/CharAsUnicode">CharAsUnicode</a>
</li><li><a class="wiki" href="https://prime.haskell.org/wiki/BinaryIO">BinaryIO</a>
</li><li><a class="wiki" href="https://prime.haskell.org/wiki/Unicode">Unicode</a>
</li></ul>Resultshttps://prime.haskell.org/ticket/16#changelog