Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. How to get qualifiers into type (Rustom Mody)
2. Re: How to get qualifiers into type (Daniel Trstenjak)
3. Re: How to get qualifiers into type (Kim-Ee Yeoh)
4. Re: How to get qualifiers into type (Rustom Mody)
5. Literate Haskell - capturing output (Martin Drautzburg)
6. Things which predictedly change over time (Martin Drautzburg)
----------------------------------------------------------------------
Message: 1
Date: Thu, 17 Jan 2013 19:10:48 +0530
From: Rustom Mody <[email protected]>
Subject: [Haskell-beginners] How to get qualifiers into type
To: beginners <[email protected]>
Message-ID:
<caj+teoe4yf1w6+6yu5detfcyhxt+rsaacfpclgwkaa3jtrl...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I am playing around with some small graph theory problems.
[Yeah I know there are good libraries -- as I said just playing around...]
And I need to do things like
type Vertex = Ix a => a
(so that a vertex can be used to index an adjacency-list-array)
That is to say that whenever 'Vertex' appears in a type signature, the Ix
should 'float' out to the qualifier list
After a lot of nudging from the error messages and rewriting as
type Vertex = forall a. Ix a => a
and giving options
LANGUAGE RankNTypes, ImpredicativeTypes, LiberalTypeSynonyms
I still get all kinds of errors. I'll report them if required. However
first of all would like to know: Is this the way to go? Is this possible?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130117/23bc2ba8/attachment-0001.htm>
------------------------------
Message: 2
Date: Thu, 17 Jan 2013 15:53:31 +0100
From: Daniel Trstenjak <[email protected]>
Subject: Re: [Haskell-beginners] How to get qualifiers into type
To: [email protected]
Message-ID: <20130117145331.GA29344@machine>
Content-Type: text/plain; charset=us-ascii
Hi Rustom,
On Thu, Jan 17, 2013 at 07:10:48PM +0530, Rustom Mody wrote:
> type Vertex = Ix a => a
> (so that a vertex can be used to index an adjacency-list-array)
Ix is a type class, so you can only create an instance for an existing type,
but not "rename" the type class to something else.
> That is to say that whenever 'Vertex' appears in a type signature, the Ix
> should 'float' out to the qualifier list
You add the constraint to the functions using the index:
element :: Ix a => a -> ListArray b -> b
element index array = ...
Greetings,
Daniel
------------------------------
Message: 3
Date: Thu, 17 Jan 2013 22:32:50 +0700
From: Kim-Ee Yeoh <[email protected]>
Subject: Re: [Haskell-beginners] How to get qualifiers into type
To: Rustom Mody <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<CAPY+ZdSbNNLyiEbJvnpJ5wZMs7_ieW=x4rusyy0onjhj6xd...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
On Thu, Jan 17, 2013 at 8:40 PM, Rustom Mody <[email protected]> wrote:
> And I need to do things like
>
> type Vertex = Ix a => a
> (so that a vertex can be used to index an adjacency-list-array)
>
Two things seem to be going on:
(1) you're trying to define a data type using "type" and not "data"+class
instances. Recall that the "type" declares a type /synonym/, and while type
synonyms seem to behave like CPP-style macros, they aren't.
> That is to say that whenever 'Vertex' appears in a type signature, the Ix
> should 'float' out to the qualifier list
>
(2) you're trying to save on keyboarding by using Vertex as a CPP-style
macro that expands in the "smart" way you just described. Something that
has been requested before is collapsing a list of constraints into just one
(search haskell-cafe archives and also see "No Module Abstraction" of [1]).
The larger the number of constraints, i.e. (A x) expands out to (B x, C x,
D x, ...) the greater the need for such a feature. But there's no benefit
to be gained here.
(3) you're trying to improve readability of code because "Ix a => a" isn't
explicit that type variable "a" is a vertex. Nothing stops you from writing
"Ix vertex => vertex" however. See [2].
[1] http://lukepalmer.wordpress.com/2010/03/19/haskells-big-three/
[2]
http://www.amateurtopologist.com/blog/2011/10/11/name-your-type-variables/
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130117/ed3db080/attachment-0001.htm>
------------------------------
Message: 4
Date: Thu, 17 Jan 2013 22:22:32 +0530
From: Rustom Mody <[email protected]>
Subject: Re: [Haskell-beginners] How to get qualifiers into type
To: Kim-Ee Yeoh <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<caj+teocyefg7_yl3znljkub85pvgi47pgpxel6difm+ystp...@mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
On Thu, Jan 17, 2013 at 9:02 PM, Kim-Ee Yeoh <[email protected]> wrote:
> On Thu, Jan 17, 2013 at 8:40 PM, Rustom Mody <[email protected]>wrote:
>
>> And I need to do things like
>>
>> type Vertex = Ix a => a
>> (so that a vertex can be used to index an adjacency-list-array)
>>
>
> Two things seem to be going on:
>
> (1) you're trying to define a data type using "type" and not "data"+class
> instances. Recall that the "type" declares a type /synonym/, and while type
> synonyms seem to behave like CPP-style macros, they aren't.
>
>
>> That is to say that whenever 'Vertex' appears in a type signature, the Ix
>> should 'float' out to the qualifier list
>>
>
> (2) you're trying to save on keyboarding by using Vertex as a CPP-style
> macro that expands in the "smart" way you just described. Something that
> has been requested before is collapsing a list of constraints into just one
> (search haskell-cafe archives and also see "No Module Abstraction" of [1]).
> The larger the number of constraints, i.e. (A x) expands out to (B x, C x,
> D x, ...) the greater the need for such a feature. But there's no benefit
> to be gained here.
>
> (3) you're trying to improve readability of code because "Ix a => a" isn't
> explicit that type variable "a" is a vertex. Nothing stops you from writing
> "Ix vertex => vertex" however. See [2].
>
> [1] http://lukepalmer.wordpress.com/2010/03/19/haskells-big-three/
>
Thanks for that link. So it seems its not possible to do what I want.
my aesthetic choice: I don?t obscure my code?s inner beauty behind
> repulsive indecipherable type signatures?
>
Vow! Thats stronger language than I am habituated to use and yes thats what
I am talking about.
And further if the type signature is already turgid and obese with
super-generic constraints, writing (... Ix vertex...) => ... instead of Ix
v just worsens it
--
http://www.the-magus.in
http://blog.languager.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130117/b9026d36/attachment-0001.htm>
------------------------------
Message: 5
Date: Thu, 17 Jan 2013 20:00:43 +0100
From: Martin Drautzburg <[email protected]>
Subject: [Haskell-beginners] Literate Haskell - capturing output
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="us-ascii"
Hello all,
I am using literate haskell quite a lot (otherwise I don't understand my own
code). This works fine for the code as such. But when I give an example usage,
I run code snippets in ghci and copy&paste into the main document/program,
which turns them into "text" (and not code).
When I make changes to the program these examples tend to no longer reflect
the actual program.
Is there a way to automatically run examples and include them in the .lhs
file, preferably with the haskell prompt and everything?
--
Martin
------------------------------
Message: 6
Date: Thu, 17 Jan 2013 21:34:36 +0100
From: Martin Drautzburg <[email protected]>
Subject: [Haskell-beginners] Things which predictedly change over time
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="us-ascii"
Hello all,
... and I thought this was easy:
find a way to represent a "schedule", i.e. a thing which assumes different
values at different days.
It turned out I don't know what a schedule is. What is the formalism behind
"This train leaves at 11:00 every day except sundays (where it doesn't run at
all), except on Easter Sunday where it leaves at 11:10"?
I do not even need to know the "most compact" representation, just some
representation which is reasonably compact and which can be translated into
human language.
So far I believe a Schedule is a function which takes a day and retuns a
Value. If I had this function, I could easily list values for all days within
given interval of days.
But the inverse should also be possible. Given a List of (Day, Value) pairs, I
should be able to construct a Schedule.
The reason why I am interested in this is the following:
"On every Monday I take a trip from A to C. To do so, I need to take two
trains and change trains in B".
So I have to consider the two train schedules to decide whether or not my
itinerary will work. So I kind of have a Constraint which is scheduled itself
(every Monday) and which depends on two other Schedules. The Constraint can be
satisfied for some days and violated for others. I want to find out when it is
violated (within a finit interval of days) without having to enumerate all
days and check each day individually.
And most importantly I want to specify the Constraint without referring to
individual days, just like I did in the quoted sentence above.
You may also say, I want to lift the fine world of relational algebra to a
world where things change over time, i.e. assume different values at different
days.
This seems to be such a common planning problem! You face it every time you
deal with things which are not constant over time, and it becomes a nightmare
when you deal with relationships between them. Still I could not find anything
useful on the net. How can the world turn at all without having this solved?
--
Martin
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 55, Issue 18
*****************************************