Re: [Haskell-cafe] monads once again: a newbie perspective

2006-08-25 Thread Andy Elvey
On Thu, 2006-08-24 at 20:53 +0200, Andrea Rossato wrote: > Hello! > > I' m new to Haskell and try to find my way through types and monads. > I tried the yet Another Haskell Tutorial, very useful for types, but > almost unreadable for monads (that's my perspective!). > Then I discovered that wonder

Re[2]: [Haskell-cafe] style question: Writer monad or unsafeIOToST?

2006-08-25 Thread Bulat Ziganshin
Hello Gregory, Friday, August 25, 2006, 3:08:09 AM, you wrote: > Some performance data: using unsafeIOToST to write log messages > directly to the output, the simulation does 10^7 state updates in > about 45 seconds > on my 1.5 GHz ppc G4. Using LogT, with a list of strings as the monoid, > i

[Haskell-cafe] a novice Alex question

2006-08-25 Thread Xiong Yingfei
Hi, I am trying out Alex. I copied the calculator specification file from Alex's official document and changed the wrapper type from "basic" to "monad". However, after I generated the ".hs" file from the lexical specification and compiled the ".hs" file, I got the message "Variable not in scope

Re: [Haskell-cafe] monads once again: a newbie perspective

2006-08-25 Thread Andrea Rossato
Il Thu, Aug 24, 2006 at 08:02:38PM +0100, Neil Mitchell ebbe a scrivere: > Just shove it on the wiki regardless. If its useless then no one will > read it. If its a bit unreadable, then people will fix it. If its > useful the world will benefit. Any outcome is a good outcome! Ok: I've put it on th

Re: [Haskell-cafe] a novice Alex question

2006-08-25 Thread Robert Dockins
On Aug 25, 2006, at 6:27 AM, Xiong Yingfei wrote: Hi, I am trying out Alex. I copied the calculator specification file from Alex's official document and changed the wrapper type from "basic" to "monad". However, after I generated the ".hs" file from the lexical specification and compiled

Re: [Haskell-cafe] USB Drivers in Haskell

2006-08-25 Thread Bjorn Bringert
On 25 aug 2006, at 05.02, Jason Dagit wrote: Hello, I recently became the owner a USB gadget that tracks movement via GPS and also tracks heart rate (it's a training device for athletes). This device comes with software that is windows only and...doesn't like up to it's potential (to put it pol

Re: Re[2]: [Haskell-cafe] style question: Writer monad or unsafeIOToST?

2006-08-25 Thread Gregory Wright
Hi Bulat, On Aug 25, 2006, at 3:36 AM, Bulat Ziganshin wrote: Hello Gregory, Friday, August 25, 2006, 3:08:09 AM, you wrote: Some performance data: using unsafeIOToST to write log messages directly to the output, the simulation does 10^7 state updates in about 45 seconds on my 1.5 GHz ppc

Re: [Haskell-cafe] a novice Alex question

2006-08-25 Thread ivan gomez rodriguez
Robert Dockins wrote: On Aug 25, 2006, at 6:27 AM, Xiong Yingfei wrote: Hi, I am trying out Alex. I copied the calculator specification file from Alex's official document and changed the wrapper type from "basic" to "monad". However, after I generated the ".hs" file from the lexical specif

[Haskell-cafe] A possible use for HSFFIG (FFIPKG) was USB Drivers in Haskell

2006-08-25 Thread Dimitry Golubovsky
Bjorn Bringert wrote: For cross-platform USB drivers, you may want to have a look at libusb [1]. I have only used it under Linux, but it seems to support Linux, *BSD and OS X. There also seems to be a win32 port [2]. A Haskell binding to libusb would be very welcome. I'm just wondering, would

Re: [Haskell-cafe] USB Drivers in Haskell

2006-08-25 Thread Jason Dagit
On 8/25/06, Bjorn Bringert <[EMAIL PROTECTED]> wrote: On 25 aug 2006, at 05.02, Jason Dagit wrote: > Hello, > > I recently became the owner a USB gadget that tracks movement via GPS > and also tracks heart rate (it's a training device for athletes). > This device comes with software that is wind

[Haskell-cafe] ghc profiling

2006-08-25 Thread Jeff Polakow
Hello,   When I compile my program without profiling:     bash-3.1$ ghc --make -auto-all -prof -O -o analysis analysis.hs     Chasing modules from: analysis.hs     Compiling Main             ( analysis.hs, analysis.o )     Linking ... everything works fine. However when I compile with profilin

[Haskell-cafe] difference between type and newtype

2006-08-25 Thread Andrea Rossato
Hello! I cannot understand this piece of code: type Z = Int type T a = Z -> (a, Z)

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Neil Mitchell
Hi type Z = Int Here you can replace all occurances of Z with Int, and its exactly the same program. newtype T1 a = T1 (Z -> (a,Z)) newtype T1 a is the same as data T1 a why mkT is a type constructor and mkT1 seems not to be? In what way is mkT a type constructor? In this program only T1

Re: [Haskell-cafe] ghc profiling

2006-08-25 Thread Jeff Briggs
On 25/08/06, Jeff Polakow <[EMAIL PROTECTED]> wrote: However when I compile with profiling: bash-3.1$ ghc --make -auto-all -prof -O -o analysis analysis.hs Chasing modules from: analysis.hs Could not find module `Data.ByteString.Lazy.Char8': use -v to see a list of the files se

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Andrea Rossato
Il Fri, Aug 25, 2006 at 07:52:35PM +0100, Neil Mitchell ebbe a scrivere: > >why mkT is a type constructor and mkT1 seems not to be? > In what way is mkT a type constructor? In this program only T1 is a > type constructor, as far as I can see. read my sentence as "why T is a type constructor and T1

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Neil Mitchell
Hi (2,5) whose type is "T a" No, try expanding the type synonyms: mkT :: a -> T a mkT :: a -> Z -> (a, Z) mkT :: a -> Int -> (a, Int) The type of (2,5) is (a, Int), or in this specific case (Int, Int). they return the same stuff with different types. Onle myT will return a type of type "T

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Brian Hulley
Andrea Rossato wrote: Hello! I cannot understand this piece of code: type Z = Int type T a = Z -> (a, Z) newtype T1 a = T1 (Z -> (a,Z)) mkT :: a -> T a mkT a = \x -> (a, x) Hi Andrea, The definition of mkT above is identical to just writing: mkT :: a -> (Z -> (a,Z)) which in turn is id

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Andrea Rossato
Il Fri, Aug 25, 2006 at 08:35:01PM +0100, Brian Hulley ebbe a scrivere: > It is maybe easier to just think of a newtype decl as being the same as a > data decl except for the fact that you can only have one constructor on the > rhs whereas a data decl allows multiple constructors, and a type decl

[Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-25 Thread Misha Aizatulin
hi, the Haskell Report 10.4 says that "The result of show is readable by read if all component types are readable" however if I define a type like data T = A | T `And` T deriving (Read, Show) then *Main> show $ A `And` A "A And A" *Main> (read "A And A") :: T *** Exception: Prelude.read

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Daniel Fischer
Am Freitag, 25. August 2006 23:55 schrieb Andrea Rossato: > Il Fri, Aug 25, 2006 at 08:35:01PM +0100, Brian Hulley ebbe a scrivere: > > It is maybe easier to just think of a newtype decl as being the same as a > > data decl except for the fact that you can only have one constructor on > > the rhs w

Re: [Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-25 Thread Robert Dockins
On Aug 25, 2006, at 6:50 PM, Misha Aizatulin wrote: hi, the Haskell Report 10.4 says that "The result of show is readable by read if all component types are readable" however if I define a type like data T = A | T `And` T deriving (Read, Show) then *Main> show $ A `And` A "A And

Re: [Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-25 Thread Neil Mitchell
Hi *Main> show $ A `And` A "A And A" For me, using GHCi 6.4.2 + Windows, I get: "A `And` A" Which all works perfectly. For reference, Hugs writes out "And A A", and then parses it back again. Hugs cannot cope with the "A `And` A" form with read, and GHC can't cope with "And A A". Thanks N

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Andrea Rossato
Il Sat, Aug 26, 2006 at 01:27:38AM +0200, Daniel Fischer ebbe a scrivere: > Because T a is a function type, namely Int -> (a,Int), so ... > iHowever, neither T1 a nor T2 a is a function type, a value of type > T1 a is a function _wrapped by the data (or value) constructor T1_ (the same > applies

Re: [Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-25 Thread Daniel Fischer
Am Samstag, 26. August 2006 00:50 schrieb Misha Aizatulin: > hi, > > the Haskell Report 10.4 says that > > "The result of show is readable by read if all component types are > readable" > > however if I define a type like > > data T = A | T `And` T deriving (Read, Show) > > then > > *Main> sh

Re: [Haskell-cafe] difference between type and newtype

2006-08-25 Thread Andrea Rossato
Il Sat, Aug 26, 2006 at 01:27:38AM +0200, Daniel Fischer ebbe a scrivere: > unT1 :: T1 a -> T a > unT1 (T1 f) = f > > makeT1 a b = unT1 (mkT1 a) b > > will work fine. *Prelude> :t makeT1 makeT1 :: a -> Int -> (a, Int) *Prelude> not that fine, though. Quite useless. try chancing to: > unT1 ::