A few days ago, for various reasons, I've started to look at Haskell.
At first I was quite impressed, after reading some FAQ, and some tutorials.
Evrything was nice and easy ... until I've started writing some code on my
own.
What I should have been told about upfront:
- the syntax for an exp
On 17 Dec 2007, at 7:39 AM, David Menendez wrote:
On Dec 17, 2007 8:51 AM, Bayley, Alistair
<[EMAIL PROTECTED]> wrote:
As an aside, I was wondering exactly what the differences are between
newtype and data i.e. between
> newtype A a = A a
and
> data A a = A a
According to:
http://www.has
On Mon, 2007-12-17 at 17:56 -0600, Derek Elkins wrote:
> Have you read Wadler's papers?
Yeah, I read the two you mentioned. While I can't say I've already
understood 100% of them, I completely agree with you in that they're the
best texts on monads, from what I've seen (maybe because they explain
On 12/17/07, Jack Kelly <[EMAIL PROTECTED]> wrote:
>
> > liftIO $ hPutStrLn h "You lose"
> > liftIO $ hFlush h
>
> IO is once again special. For other inner monads, the lift function
> does the same thing. Note also that IO has no transformer and must
> therefore always be the innermost monad.
Ac
Thanks for the timings. Alas, I'm leaving in the morning for vacation, so
I'm not sure when I'll have time to profile these operations. And I'm
still puzzling over how to speed up darcs get (i.e. the long discussion of
http pipelining, which will not, of course, do anything to help the poor
folks
On Mon, 2007-12-17 at 21:22 -0200, Andre Nathan wrote:
> On Mon, 2007-12-17 at 17:33 -0200, Andre Nathan wrote:
> > Hello (Newbie question ahead :)
>
> Thanks everyone for the great suggestions. The code is much cleaner now
> (not to mention it works :)
>
> This is the first non-tutorial program
I sent this to a friend who asked me about monad transformers and he
reckons it should be saved somewhere. If anyone feels up to giving it a
quick fact-check, that'd be great. I'm not sure what to do with it,
though. It doesn't seem to be made of the right stuff for a tutorial but
I'm not sure
Miguel Mitrofanov <[EMAIL PROTECTED]> writes:
> I've noticed it, but there are some problems with this
> representation, so I decided not to mention it. It's OK as far as we
> don't want functions working on two areas - I don't see, how we can
> implement, say, intersect :: Shape -> Shape -> Bool
On Mon, 2007-12-17 at 17:33 -0200, Andre Nathan wrote:
> Hello (Newbie question ahead :)
Thanks everyone for the great suggestions. The code is much cleaner now
(not to mention it works :)
This is the first non-tutorial program I'm writing and all this monad
stuff is easier than I thought it wou
On Mon, 2007-12-17 at 22:12 +0300, Miguel Mitrofanov wrote:
> > There's a third way, too, and I haven't seen anybody mention it yet
>
> I've noticed it, but there are some problems with this
> representation, so I decided not to mention it. It's OK as far as we
> don't want functions working o
On Dec 17, 2007 1:04 PM, Brandon S. Allbery KF8NH <[EMAIL PROTECTED]> wrote:
>
> On Dec 17, 2007, at 15:41 , Brent Yorgey wrote:
>
> > Yes, and in fact, you don't even need foldM. The only thing that
> > actually uses IO is the readFile, so ideally
>
> Actually, a quick check indicates that the re
On Mon, 17 Dec 2007 16:04:24 -0500
"Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]> wrote:
>
> On Dec 17, 2007, at 15:41 , Brent Yorgey wrote:
>
> > Yes, and in fact, you don't even need foldM. The only thing that
> > actually uses IO is the readFile, so ideally
>
> Actually, a quick check ind
On Dec 17, 2007, at 15:41 , Brent Yorgey wrote:
Yes, and in fact, you don't even need foldM. The only thing that
actually uses IO is the readFile, so ideally
Actually, a quick check indicates that the regex functions used in
getProcInfo are in IO as well (?!).
--
brandon s. allbery [sol
> This is what I have so far:
>
> > type Pid = FilePath
> > type Uid = String
> >
> > type PsData = Map String Uid
> > type PsChildren = Map Pid PsInfo
> >
> > data PsInfo = PsInfo PsData PsChildren
> > type PsMap = Map Pid PsInfo
> > type PsTree = Map Pid PsInfo
> >
> > parent :: PsData -> Pi
Am Montag, 17. Dezember 2007 21:06 schrieb ChrisK:
> Andre Nathan wrote:
> > Hello (Newbie question ahead :
> >
> > I tried this for insertProc, but it obviously doesn't work... what would
> > be the correct way to do this?
> >
> >> insertProc :: Pid -> StateT PsMap IO PsInfo
> >> insertProc pid =
Ø However, the readme.html file has the following note:
That should have been the GLFW readme.html file
PS: Why do I always see these errors *after* I already posted to the forum?
;) This is actually one advantage of web-based forums, you can always edit
the original message J
Fr
On Dec 17, 2007, at 14:33 , Andre Nathan wrote:
insertProc :: Pid -> StateT PsMap IO PsInfo
insertProc pid = do
proc <- procInfo pid -- XXX this is obviously wrong...
proc <- lift $ procInfo pid
psMap <- get
put (Map.insert pid proc psMap)
modify (Map.insert pid proc) -- same as
Hi,
This might be a tip for people trying to compile the GLFW package bundled
with SOE on Windows. I had to because I slightly modified the GLFW source
code.
The SOE readme.txt says:
"For Win32 users, you'll need MinGW environment to compile
GLFW. If "make win32-mgw" is unable to execu
Andre Nathan wrote:
> Hello (Newbie question ahead :
>
> I tried this for insertProc, but it obviously doesn't work... what would
> be the correct way to do this?
>
>> insertProc :: Pid -> StateT PsMap IO PsInfo
>> insertProc pid = do
>> proc <- procInfo pid -- XXX this is obviously wrong...
>>
> I interpreted Evan's question as "why can't you have newtypes with
> multiple fields?" -- i.e., newtype X = X A B C -- and that's the
> question I was answering. But maybe I misunderstood.
Well, the question was both, and "strictness" answers both. Thanks
for the clarification. I should have r
Luke Palmer wrote:
There was a thread about this recently.
In any case, if you load the code interpreted (which happens if there
is no .o or .hi file of the module lying around), then you can
look inside all you want. But if it loads compiled, then you only
have access to the exported symbols.
Excellent! This has all been very helpful. Thanks a lot everybody! :-)
-Corey
On 12/14/07, Benja Fallenstein <[EMAIL PROTECTED]> wrote:
> Hi Corey,
>
> On Dec 14, 2007 8:44 PM, Corey O'Connor <[EMAIL PROTECTED]> wrote:
> > The reason I find all this odd is because I'm not sure how the type
> > cla
Hello (Newbie question ahead :)
I'm trying to write a program which will build a tree (here represented
as a Map) of unix processes. The tree should be built by reading the
process information stored in /proc/PID/status. There is also another
Map which will be used for faster insertions on the pr
On 12/17/07, Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote:
> This is not a generalization of what you talked about. Why should the tuple
> type be unboxed? Tuple types are boxed, meaning there is a difference
> between _|_ and (_|_,…,_|_). If you write
>
> newtype X = X (A, B, C)
>
> then X do
I installed ghc 6.6.1 and 0.9.12.1. I'm trying to use the tree view widget.
To enable search in treeview, I added following 2 lines:
New.treeViewAppendColumn view col3
-- my addition
New.treeViewSetEnableSearch view True
New.treeViewSetSearchColumn view 0
in demo/treeList/TreeDemo.hs
Th
There's a third way, too, and I haven't seen anybody mention it yet
I've noticed it, but there are some problems with this
representation, so I decided not to mention it. It's OK as far as we
don't want functions working on two areas - I don't see, how we can
implement, say, intersect :: S
Am Montag, 17. Dezember 2007 19:26 schrieb Tim Chevalier:
> On 12/17/07, Evan Laforge <[EMAIL PROTECTED]> wrote:
> > I'm sure there's a trivial explanation for this, but here's something
> > that I've always kind of wondered about: Given a single constructor
> > type like "data X = X A B C" can't
There was a thread about this recently.
In any case, if you load the code interpreted (which happens if there
is no .o or .hi file of the module lying around), then you can
look inside all you want. But if it loads compiled, then you only
have access to the exported symbols. The reason is becaus
Adam Smyczek gmail.com> writes:
[...]
> But when I extract a and b to constants:
>
> c_a = "a" :: String
> c_b = "b" :: String
>
> case name of
> c_a -> ...
> c_b -> ...
> I get Patterns match(es) are overlapped.
Do you require 'name' and the constants to be of type String?
If not
On Mon, 2007-12-17 at 09:58 -0500, David Menendez wrote:
>
>
> On Dec 17, 2007 4:34 AM, Yitzchak Gale <[EMAIL PROTECTED]> wrote:
> Derek Elkins wrote:
> > There is another very closely related adjunction that is
> less often
> > mentioned.
> >
> > (
On 12/17/07, Evan Laforge <[EMAIL PROTECTED]> wrote:
> Oops, nevermind, I just saw the other thread and link to
> http://www.haskell.org/haskellwiki/Newtype. Ok, so that seems like a
> pretty subtle diffenence... I'm assuming the rationale behind
> differentiating between a single constructor data
On 12/17/07, Evan Laforge <[EMAIL PROTECTED]> wrote:
> I'm sure there's a trivial explanation for this, but here's something
> that I've always kind of wondered about: Given a single constructor
> type like "data X = X A B C" can't that be transformed into "newtype X
> = X (A, B, C)"? There must
> I'm sure there's a trivial explanation for this, but here's something
> that I've always kind of wondered about: Given a single constructor
> type like "data X = X A B C" can't that be transformed into "newtype X
> = X (A, B, C)"? There must be some difference, because if there
> weren't we cou
> A newtype can only have one constructor, with one argument, and is
> essentially a wrapper for that argument type.
>
> In the general case, you want to use "data" instead of "newtype":
>
> data Rectangle = R Int Int
I'm sure there's a trivial explanation for this, but here's something
that I'v
On Mon, 2007-12-17 at 13:51 +, Bayley, Alistair wrote:
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark
> >
> > To recap...
> >
> > "type" introduces a synonym for another type, no new type is
> > createdit's for readabilities sake.
> >
> > "Newtype"
I found
http://haskell.cs.yale.edu/haskell-report/List.html
had many useful "one off" type list functions such as "subsequences" and
"permutations" which are nowhere to be found in hoogle, Data.List, or the
haskell hierarchical libs
Shouldn't these be included somewhere?
thomas.
---
Thomas Davie wrote:
Take a look at the Typable class. Although, pretty much any code that
you can compile can be loaded into ghci without modification, and that's
by far the easier way of finding the types of things.
Is there a way to make ghci to know also the symbols which are not exported?
Peter Verswyvelen wrote:
Very interesting, I did not know that!
I thought newtype was an optimization of data, and that "newtype" was bad
terminology. But if newtype is just a wrapper around a type, then the name is choosen
well.
I'm a bit confused why then one needs a data-constructor-like t
Thomas Davie <[EMAIL PROTECTED]> writes:
> Yes, and you can indeed do a similar thing in Haskell. The natural
> thing to do here would be to define a type Shape...
> data Shape = Circle Int
> | Rectangle Int Int
> | Square Int
> If however, you *really* want to keep your
Very interesting, I did not know that!
I thought newtype was an optimization of data, and that "newtype" was bad
terminology. But if newtype is just a wrapper around a type, then the name is
choosen well.
I'm a bit confused why then one needs a data-constructor-like tag to construct
a newtype
joelr1:
> On Dec 17, 2007, at 4:30 PM, Peter Verswyvelen wrote:
>
> >Maybe you could place Yampa in a Darcs depot?
>
>
> darcs get http://wagerlabs.com/yampa
>
> I think we should move it to Google Code, though.
How about code.haskell.org ?
Get yr accounts here,
http://community.haskell.
On Dec 17, 2007, at 4:30 PM, Peter Verswyvelen wrote:
Maybe you could place Yampa in a Darcs depot?
darcs get http://wagerlabs.com/yampa
I think we should move it to Google Code, though.
--
http://wagerlabs.com
___
Haskell-Cafe mailing list
H
My Haskell is not up to understanding themI'm still writing hello
world programswhat I read, gave me a good initial hint as to whats
going on...I just need to get my Haskell going before I can jump in the
deep end.
-Original Message-
From: Bulat Ziganshin [mailto:[EMAIL PROTECTED]
Roman Leshchinskiy wrote:
Andrew Coppin wrote:
Then Mr C++ looked at it and said "OMG! You don't *never* use
strlen() inside a loop!" and the second version was writting:
Nice. I especially like the way it'll segfault if there is a blank at
the end of the file.
That's why I love C so much.
Am Montag, 17. Dezember 2007 13:04 schrieb Jed Brown:
> […]
> When your type only has one constructor, newtype is preferred over data, but
> they are semantically equivalent.
They are *not* semantically equivalent, as has already been said more or less.
data adds an extra level of indirection.
Hello Mark,
Monday, December 17, 2007, 4:47:50 PM, you wrote:
> I'll give it a read.
> http://www.haskell.org/haskellwiki/OOP_vs_type_classes
i recommend you to read two papers mentioned in References section
there. at least i'm one of this page authors and i don't think that i
had very good u
Maybe you could place Yampa in a Darcs depot?
I will have some time now to study Yampa and apps again. To train myself, I
would try to make a simple bouncing ball, then a Pong like game, and then I
would like to convert the C++ minigames I made for my students. These might
serve as simple tutoria
Hi Peter,
Oops!
Yes, as Paul says, clearly an error.
My best guess is that it was commented out at some point for testing
something, and then forgotten!
The error does not occur in my local copy of the code, so a version
skew problem to boot, I'm afraid.
Best,
/Henrik
--
Henrik Nilsson
Scho
No neither do II think we can drop that bitI think I got
confused about it for a second.not unsurprisingly.
From: Brent Yorgey [mailto:[EMAIL PROTECTED]
Sent: 17 December 2007 15:38
To: Nicholls, Mark
Cc: Thomas Davie; Haskell Cafe
Subject: Re: [Ha
On Dec 17, 2007 8:51 AM, Bayley, Alistair <
[EMAIL PROTECTED]> wrote:
> As an aside, I was wondering exactly what the differences are between
> newtype and data i.e. between
>
> > newtype A a = A a
>
> and
>
> > data A a = A a
>
> According to:
> http://www.haskell.org/onlinereport/decls.html#sec
On Dec 17, 2007 8:04 AM, Nicholls, Mark <[EMAIL PROTECTED]> wrote:
> No that's fineits all as clear as mud!..but that's not your
> fault.
>
> To recap...
>
> "type" introduces a synonym for another type, no new type is
> createdit's for readabilities sake.
>
> "Newtype" introduces an i
Dear all,
When I run the program below a window appears for a split second, then
disappears and the program exits. Can you help me figure out what's
going wrong?
***
import Graphics.Win32.Misc
import Graphics.Win32.GDI.Types
import Graphics.Win32.Window
import System.Win32.DLL
import Foreign
On Dec 17, 2007 8:18 AM, Nicholls, Mark <[EMAIL PROTECTED]> wrote:
> The approach is deliberate...but I accept may be harder than it needs to
> be...I'm interested in Haskell because of the alleged power/formality of
> it's type system against the relatively weakness of OO ones...the irony
> at th
Certainly looks like a typo to me!
Peter Verswyvelen wrote:
While studying the vector space class in AFRP, I encountered the following
strange code:
class Floating a => VectorSpace v a | v -> a where
...
v1 ^-^ v2 = v1 ^+^ v1 -- (negateVector v2)
I have no idea why the (negateVector v2)
On Dec 17, 2007 4:34 AM, Yitzchak Gale <[EMAIL PROTECTED]> wrote:
> Derek Elkins wrote:
> > There is another very closely related adjunction that is less often
> > mentioned.
> >
> > ((-)->C)^op -| (-)->C
> > or
> > a -> b -> C ~ b -> a -> C
> >
> > This gives rise to the monad,
> > M a = (a -> C)
> From: Bayley, Alistair
>
> Sorry, that should read:
>
> > newtype A = A a
> > data A = A a
Ignore that; I was right first time. Sorry 'bout the spam, and the lack
of brain.
*
Confidentiality Note: The information contained in thi
> From: Bayley, Alistair
>
> > newtype A a = A a
> and
> > data A a = A a
Sorry, that should read:
> newtype A = A a
> data A = A a
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark
>
> To recap...
>
> "type" introduces a synonym for another type, no new type is
> createdit's for readabilities sake.
>
> "Newtype" introduces an isomorphic copy of an existing type...but
> doesn't copy it's
Ahhh
I'll give it a read.
thanks
-Original Message-
From: Henning Thielemann [mailto:[EMAIL PROTECTED]
Sent: 17 December 2007 13:05
To: Nicholls, Mark
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] OOP'er with (hopefully) trivial
questions.
On Mon, 17 Dec 2007, Nicholls,
On Dec 17, 2007 1:18 PM, Nicholls, Mark <[EMAIL PROTECTED]> wrote:
> Not really with this...
>
> The open case (as in OO) seems to be more like the Haskell class
> construct, i.e. if new types declare themselves to be members of a class
> then they must satisfy certain constaintsI can then spec
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Nicholls, Mark
>
> The open case (as in OO) seems to be more like the Haskell class
> construct, i.e. if new types declare themselves to be members
> of a class
> then they must satisfy certain constaintsI can then
> specify
Not really with this...
The open case (as in OO) seems to be more like the Haskell class
construct, i.e. if new types declare themselves to be members of a class
then they must satisfy certain constaintsI can then specify "equals"
with the class and leave the onus on the implementor to impleme
On Mon, 17 Dec 2007, Nicholls, Mark wrote:
> After many years of OOP though my brain is wired up to construct
> software in that 'pattern'a problem for me at the moment is I cannot
> see how to construct programs in an OO style in HaskellI know this
> is probably not the way to approach i
No that's fineits all as clear as mud!..but that's not your
fault.
To recap...
"type" introduces a synonym for another type, no new type is
createdit's for readabilities sake.
"Newtype" introduces an isomorphic copy of an existing type...but
doesn't copy it's type class membership..
Nicholls, Mark wrote:
data Shape = Circle Int
| Rectangle Int Int
| Square Int
Isn't this now "closed"...i.e. the statement is effectively defining
that shape is this and only ever thisi.e. can I in another module
add new "types" of Shape?
Yes, but in most case
On 17 Dec 2007, at 12:22, Nicholls, Mark wrote:
Ok...
Thanks I need to revisit data and newtype to work out what the
difference is I think.
Beware in doing so -- type, and newtype are not the same either. type
creates a type synonim. That is, if I were to declare
type Jam = Int
then J
David Roundy wrote:
I am pleased to announce the availability of the second prerelease of darcs
two, darcs 2.0.0pre2.
Thanks!
Continuing my performance tests, I tried unpulling and re-pulling a bunch
of patches in a GHC tree. I'm unpulling about 400 patches using
--from-tag, and then pullin
Ok...
Thanks I need to revisit data and newtype to work out what the
difference is I think.
-Original Message-
From: Jed Brown [mailto:[EMAIL PROTECTED] On Behalf Of Jed Brown
Sent: 17 December 2007 12:04
To: Nicholls, Mark
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] OOP'er w
Dominic Steinitz wrote:
Roberto Zunino wrote:
This is the point: eta does not hold if seq exists.
undefined `seq` 1 == undefined
(\x -> undefined x) `seq` 1 == 1
Ok I've never used seq and I've never used unsavePerformIO. Provided my
program doesn't contain these then can I assume that eta
On 17 Dec 2007, [EMAIL PROTECTED] wrote:
> Ooo
>
> "The constructor of a newtype must have exactly one field but `R' has
> two In the newtype declaration for `Rectangle'"
>
> It doesn't like
>
> "newtype Rectangle = R Int Int"
You want
data Rectangle = R Int Int
A newtype declaration will be
On Dec 17, 2007 10:47 PM, Nicholls, Mark <[EMAIL PROTECTED]> wrote:
> "The constructor of a newtype must have exactly one field but `R' has
> two In the newtype declaration for `Rectangle'"
>
> It doesn't like
>
> "newtype Rectangle = R Int Int"
A newtype can only have one constructor, with one
Ooo
"The constructor of a newtype must have exactly one field but `R' has
two In the newtype declaration for `Rectangle'"
It doesn't like
"newtype Rectangle = R Int Int"
-Original Message-
From: Thomas Davie [mailto:[EMAIL PROTECTED]
Sent: 17 December 2007 11:04
To: Nicholls, Mark
C
I have received patches which will help Cabal make ghc-6.6 and gc-6.8 friendly
regex-tdfa. The problem below is from a change in STUArray from 3 to 4
parameters going from 6.6 to 6.8. I think adding another '_' to each pattern
match makes it work for 6.8.
Once I get these patches working locally
On 17 Dec 2007, at 11:14, Nicholls, Mark wrote:
OK I'll have to digest this and mess about a bitbut can I make an
observation at this point
If I define "Shape" like
data Shape = Circle Int
| Rectangle Int Int
| Square Int
Isn't this now "closed"...i.e. the sta
OK I'll have to digest this and mess about a bitbut can I make an
observation at this point
If I define "Shape" like
data Shape = Circle Int
| Rectangle Int Int
| Square Int
Isn't this now "closed"...i.e. the statement is effectively defining
that shape is this
"Nicholls, Mark" <[EMAIL PROTECTED]> writes:
> After many years of OOP though my brain is wired up to construct software in
> that ?pattern??.a problem for me at the moment is I cannot see how to
> construct
> programs in an OO style in Haskell?.I know this is probably not the way to
> approach i
On 17 Dec 2007, at 10:46, Nicholls, Mark wrote:
I can obviously at a later date add a new class Triangle, and not
have to touch any of the above code….
Yes, and you can indeed do a similar thing in Haskell. The natural
thing to do here would be to define a type Shape...
data Shape = Ci
I'm trying to teach myself HaskellI've spent a few hours going
through a few tutorialsand I sort of get the basics...
My interest in Haskell is specifically around the strength of the type
system.
After many years of OOP though my brain is wired up to construct
software in that 'pat
Derek Elkins wrote:
> There is another very closely related adjunction that is less often
> mentioned.
>
> ((-)->C)^op -| (-)->C
> or
> a -> b -> C ~ b -> a -> C
>
> This gives rise to the monad,
> M a = (a -> C) -> C
> this is also exactly the comonad it gives rise to (in the op category
> which e
On Sun, 2007-12-16 at 15:21 -0800, Don Stewart wrote:
> An updated bytestring library is at :
>
>
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-0.9.0.2
>
> Enjoy! :)
Thanks!
-Peter
___
Haskell-Cafe mailing list
Haskel
80 matches
Mail list logo