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. Re: Partial Loading and Debugging with GHCI (Edward Z. Yang)
2. Re: Partial Loading and Debugging with GHCI (Alexander Dunlap)
3. Installing Yi With GTK Frontend (aditya siram)
4. Re: Installing Yi With GTK Frontend (Jeff Wheeler)
5. Question on Lists (Nathan Holden)
6. Re: Question on Lists (Alexander Dunlap)
7. data constructors (Michael Mossey)
8. Re: data constructors (Michael Mossey)
9. Re: data constructors (Daniel Fischer)
----------------------------------------------------------------------
Message: 1
Date: Thu, 16 Apr 2009 23:34:52 -0400 (EDT)
From: "Edward Z. Yang" <[email protected]>
Subject: Re: [Haskell-beginners] Partial Loading and Debugging with
GHCI
To: aditya siram <[email protected]>
Cc: [email protected]
Message-ID: <alpine.deb.2.00.0904162333300.6...@javelin>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
On Thu, 16 Apr 2009, aditya siram wrote:
> I'm curious as to how one would go about debugging the following program:
Alternatively, instead of trying to find out what the type is (which
might something completely unintelligible and unhelpful, due to
Haskell's type inferencing), use :: liberally on subexpressions to say
"I think the type here should be *blah*"; it will let you zoom in on the
compiler-human mismatch much more quickly. I think this is one of the
best ways of Haskell debugging.
Cheers,
Edward
------------------------------
Message: 2
Date: Thu, 16 Apr 2009 22:21:20 -0700
From: Alexander Dunlap <[email protected]>
Subject: Re: [Haskell-beginners] Partial Loading and Debugging with
GHCI
To: "Edward Z. Yang" <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Thu, Apr 16, 2009 at 8:34 PM, Edward Z. Yang <[email protected]> wrote:
> On Thu, 16 Apr 2009, aditya siram wrote:
>>
>> I'm curious as to how one would go about debugging the following program:
>
> Alternatively, instead of trying to find out what the type is (which
> might something completely unintelligible and unhelpful, due to
> Haskell's type inferencing), use :: liberally on subexpressions to say
> "I think the type here should be *blah*"; it will let you zoom in on the
> compiler-human mismatch much more quickly. I think this is one of the
> best ways of Haskell debugging.
>
> Cheers,
> Edward
> _______________________________________________
I use this technique a lot. By telling the compiler more and more
about what you think out to be going on, you can ascertain much more
quickly where you disagree with the compiler.
Alex
------------------------------
Message: 3
Date: Fri, 17 Apr 2009 13:11:57 -0500
From: aditya siram <[email protected]>
Subject: [Haskell-beginners] Installing Yi With GTK Frontend
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
I am having issues installing Yi with the GTK frontend. I have GTK2hs
installed correctly but when I do 'yi --help' I get:
Usage: yi [option...] [file]
--self-check run self-checks
-f [frontend] --frontend=[frontend] Select frontend, which can be one
of:
vty
-y path --config-file=path Specify a configuration file
-V --version Show version information
-h --help Show this help
--debug Write debug information in a log
file
-l [num] --line=[num] Start on line number
--as=[editor] Start with editor keymap, where
editor is one of:
emacs, vim, cua
--recompile-force Force recompile of custom yi before
starting
--resume Resume execution of yi from previous
state
--recompile Recompile custom yi if required then
exit
--ghc-options=[flags] Flags to pass to GHC
Does Yi need a specific version of Gtk2hs?
Thanks ...
-deech
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090417/b8ce2fe0/attachment-0001.htm
------------------------------
Message: 4
Date: Sat, 18 Apr 2009 19:57:31 -0500
From: Jeff Wheeler <[email protected]>
Subject: Re: [Haskell-beginners] Installing Yi With GTK Frontend
To: [email protected]
Message-ID: <1240102651.22866.17.ca...@ulysses>
Content-Type: text/plain
On Fri, 2009-04-17 at 13:11 -0500, aditya siram wrote:
> I am having issues installing Yi with the GTK frontend. I have GTK2hs
> installed correctly but when I do 'yi --help' I get:
> Does Yi need a specific version of Gtk2hs?
It should work on 0.10; I'm not sure about earlier versions.
What happens if you try to run `cabal install yi -fpango`? Also, can you
try installing the development version? That might provide more insight
the problem, as I'm not immediately sure what's wrong.
To get the latest version from the darcs repository, try this:
$ darcs get http://code.haskell.org/yi/
$ cd yi
$ cabal install -fpango
And then, try execution via (the -fpango should be the default, but no
harm in being verbose)
$ yi -fpango
Do you get any errors at this point?
Jeff Wheeler
(Oh, and I apologize to aditya siram; I initially sent this message
privately, rather than to the list.)
------------------------------
Message: 5
Date: Sun, 19 Apr 2009 15:24:15 -0400
From: Nathan Holden <[email protected]>
Subject: [Haskell-beginners] Question on Lists
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I have been reading Chris Okasaki's PhD thesis on Purely Functional Data
Structures (www.cs.cmu.edu/~rwh/theses/*okasaki*.pdf) and it discusses his
idea of lazy lists (He uses Standard ML in the paper), and it raised some
questions for me.
To cut to the chase, my question is this:
Say I have list x of length n, and I have a single piece of data y. Does
x ++ [y]
take more cycles, or the same as if I'd said y:[x] (which would get it on
the wrong side?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090419/cd6460bc/attachment-0001.htm
------------------------------
Message: 6
Date: Sun, 19 Apr 2009 13:44:03 -0700
From: Alexander Dunlap <[email protected]>
Subject: Re: [Haskell-beginners] Question on Lists
To: Nathan Holden <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Sun, Apr 19, 2009 at 12:24 PM, Nathan Holden <[email protected]> wrote:
> I have been reading Chris Okasaki's PhD thesis on Purely Functional Data
> Structures (www.cs.cmu.edu/~rwh/theses/okasaki.pdf) and it discusses his
> idea of lazy lists (He uses Standard ML in the paper), and it raised some
> questions for me.
>
> To cut to the chase, my question is this:
>
> Say I have list x of length n, and I have a single piece of data y. Does
> Â x ++ [y]
> take more cycles, or the same as if I'd said y:[x] (which would get it on
> the wrong side?)
>
y:x is O(1), while x ++ [y] is O(n), where n is the number of elements
in x. This is because in order to do x ++ [y], you need to traverse
all of the elements in x to get to the end, while y:x just puts it
onto the front, which is readily available without a traversal.
y:[x] is a type error, because that is the same as saying [y,x], but y
and x are not the same type so they can't be in a list together.
Alex
------------------------------
Message: 7
Date: Sun, 19 Apr 2009 14:30:28 -0700
From: Michael Mossey <[email protected]>
Subject: [Haskell-beginners] data constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
This is probably a side-effect of coming from OO land, but I'm confused about
how to
organize my data. Let's say I want to model musical information that occurs on
a
single staff. A staff consists of a list of StaffItem which occurs at specific
times.
type Time = Double
type Staff = [(Time,StaffItem)]
A StaffItem can be one of several things. Let's say it can be a "chord" or a
"control". I might like to define Chord and Control first:
data Chord = Chord { duration :: Double, notes :: [Note] }
data Control = DynamicMark Int
| TempoMark Int
Okay, so now I want to express the idea a StaffItem can be a Chord or a Control.
data StaffItem = StaffItemChord Chord
| StaffItemControl Control
My problem is the awkward need for separately named constructors
"StaffItemChord"
and "StaffItemControl". Is there a better way? (Is this even right?)
Thanks,
Mike
------------------------------
Message: 8
Date: Sun, 19 Apr 2009 17:10:42 -0700
From: Michael Mossey <[email protected]>
Subject: Re: [Haskell-beginners] data constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Some additional thoughts:
Here is something I'm struggling with. Let's say a piece of music is several
staves
filled with chords. Staves have names. Each chord in a staff has a time.
In informal notation:
staff "fred": (time 1.0, chord 1), (time 1.5, chord 2), (time 2.0, chord 3)
staff "bob" : (time 1.0, chord 4), (time 2.0, chord 5)
When laying out music, I need to find "verticals", which are chords located on
different staves which happen to coincide in time. For instance, the above has
three
verticals:
time 1.0: ("fred", chord 1), ("bob", chord 4)
time 1.5: ("fred", chord 2)
time 2.0: ("fred", chord 3), ("bob", chord 5)
I want to write a function that converts the first way of organizing the
information
into the second. I tried writing types like
type Chord = ...
type Time = Double
type Name = String
type TimedChord = (Time,Chord)
type Staff = [(Time,Chord)]
type NamedStaff = (Name,Staff)
type NamedChord = (Name,Chord)
type Vertical = [NamedChord]
type TimedVertical = (Time,Vertical)
The function I want is
convert :: [NamedStaff] -> [TimedVertical]
As you can imagine, this is a confusing mess, with all these variants on named
and
timed things. I thought it might help to create functors called Named and
Timed,
which might help abstracting operations on named and timed things. For example,
datatype Named a = Named { namedName :: Name, namedData :: a }
instance Functor Named =
name a :: Name
name a = namedName a
x `fmap` f = Named { namedName = namedName x, namedData = f $ namedData x }
Any other suggestions?
Thanks,
Mike
------------------------------
Message: 9
Date: Mon, 20 Apr 2009 02:52:48 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] data constructors
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Montag 20 April 2009 02:10:42 schrieb Michael Mossey:
> Some additional thoughts:
>
> Here is something I'm struggling with. Let's say a piece of music is
> several staves filled with chords. Staves have names. Each chord in a staff
> has a time.
>
> In informal notation:
>
> staff "fred": (time 1.0, chord 1), (time 1.5, chord 2), (time 2.0, chord
> 3) staff "bob" : (time 1.0, chord 4), (time 2.0,
> chord 5)
>
> When laying out music, I need to find "verticals", which are chords located
> on different staves which happen to coincide in time. For instance, the
> above has three verticals:
>
> time 1.0: ("fred", chord 1), ("bob", chord 4)
> time 1.5: ("fred", chord 2)
> time 2.0: ("fred", chord 3), ("bob", chord 5)
>
> I want to write a function that converts the first way of organizing the
> information into the second. I tried writing types like
>
> type Chord = ...
> type Time = Double
> type Name = String
>
> type TimedChord = (Time,Chord)
> type Staff = [(Time,Chord)]
> type NamedStaff = (Name,Staff)
> type NamedChord = (Name,Chord)
> type Vertical = [NamedChord]
> type TimedVertical = (Time,Vertical)
>
> The function I want is
>
> convert :: [NamedStaff] -> [TimedVertical]
What about
import Data.Function (on)
import Data.List
convert namedStaffs = map timeVertical verticals
where
nameTimedChords (name,tcs) = [(time,name,chord) | (time, chord) <- tcs]
timedNamedChords = sort . foldr merge [] . map nameTimedChords $
namedStaffs
fst3 (x,_,_) = x
verticals = groupBy ((==) `on` fst3) timedNamedChords
timeVertical v@((t,_,_):_) = (t,[(name,chord) | (_,name,chord) <- v])
?
>
> As you can imagine, this is a confusing mess, with all these variants on
> named and timed things. I thought it might help to create functors called
> Named and Timed, which might help abstracting operations on named and timed
> things. For example,
>
> datatype Named a = Named { namedName :: Name, namedData :: a }
>
> instance Functor Named =
> name a :: Name
> name a = namedName a
> x `fmap` f = Named { namedName = namedName x, namedData = f $ namedData
> x }
>
> Any other suggestions?
> Thanks,
> Mike
>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 10, Issue 17
*****************************************