Re: [Haskell-cafe] Trouble with types

2009-06-01 Thread Vladimir Reshetnikov
Hi Daniel, Could you please explain what does mean 'monomorphic' in this context? I thought that all type variables in Haskell are implicitly universally quantified, so (a -> a) is the same type as (forall a. a -> a) Thank you, Vladimir On 6/1/09, Daniel Fischer wrote: > Am Montag 01 Juni 2009

Re: [Haskell-cafe] Possible Haskell Project

2009-06-01 Thread Antoine Latter
On Mon, Jun 1, 2009 at 11:18 PM, Tom Hawkins wrote: > My family and I are moving in the coming months.  My wife will be > attending a new school in the fall.  Among the many hassles of moving > are locating and transferring medical records to new doctors and > clinics.  During our time in Minnesot

[Haskell-cafe] Possible Haskell Project

2009-06-01 Thread Tom Hawkins
My family and I are moving in the coming months. My wife will be attending a new school in the fall. Among the many hassles of moving are locating and transferring medical records to new doctors and clinics. During our time in Minnesota, we've visited several clinics and hospitals, so our medica

Re: [Haskell-cafe] Checking a value against a passed-in constructor?

2009-06-01 Thread Richard O'Keefe
On 2 Jun 2009, at 3:39 pm, Dan Cook wrote: Hi, (Relatively new to Haskell here ..) So I have the following: data MyVal = Atom String | Bool Bool And I want to do something like this check :: (Bool -> MyVal) -> MyVal -> True check f (f x) = True check _ _ = False Wh

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread Ryan Ingram
> graph5.hs:37:9: > Warning: No explicit method nor default method for `mzero' > In the instance declaration for `MonadPlus Failable' This warning is saying you didn't finish the declaration. Try something like instance MonadPlus Failable where mplus (Fail _) y = y mplus x _ = x

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread michael rice
I didn't know I could do that. Works fine. Output below. Thanks! This is some pretty neat stuff, and I've only scratched the surface. Michael === [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help Loading package ghc-prim ... linking ... d

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread Ross Mellgren
Oh I wasn't clear -- you need multiple instance declarations for a given type (Failable, for example), one for each type class you're implementing. That is, instance Monad Failable where return = ... ... instance MonadPlus Failable where mplus = ... ... -Ross On Jun 1, 2009,

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread michael rice
Hi Ross, I thought of that, but return, fail, and >>= became "not visible" when I changed the instance declaration from Monad to MonadPlus.. Can Failable be in two instance declarations, one for Monad (giving it return, fail, and >>=) and one for MonadPlus (giving it mplus)? Michael --- On Mo

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread Ross Mellgren
mplus is a method of class MonadPlus, so you need to write it in a separate instance from the one for Monad, e.g. instance MonadPlus Failable where mplus = ... -Ross On Jun 1, 2009, at 9:28 PM, michael rice wrote: Still stumped. Maybe and [] are in the same MonadPlus monad, but how do

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread michael rice
Still stumped. Maybe and [] are in the same MonadPlus monad, but how do I make monad Failable understand mplus? I'm now getting this error upon loading: Prelude> :l graph5 [1 of 1] Compiling Main ( graph5.hs, interpreted ) graph5.hs:36:4: `mplus' is not a (visible) method of class

Re: [Haskell-cafe] Checking a value against a passed-in constructor?

2009-06-01 Thread Jason Dagit
Hi Dan, On Mon, Jun 1, 2009 at 8:39 PM, Dan Cook wrote: > Hi, > (Relatively new to Haskell here ..) > > So I have the following: > > data MyVal = Atom String >| Bool Bool > > And I want to do something like this > > check :: (Bool -> MyVal) -> MyVal -> True > check f (f

[Haskell-cafe] Checking a value against a passed-in constructor?

2009-06-01 Thread Dan Cook
Hi, (Relatively new to Haskell here ..) So I have the following: data MyVal = Atom String | Bool Bool And I want to do something like this check :: (Bool -> MyVal) -> MyVal -> True check f (f x) = True check _ _ = False What that means is I want to pass a MyVal constr

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-06-01 Thread Sebastian Fischer
Do you argue that overloading logical operations like this in Haskell sacrifices type safety? Could programs "go wrong" [1] that use such abstractions? If I understand your point correctly, you are suggesting that such programs are still type safe. My asking was really meant as a question t

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread michael rice
Got it. Thanks! Michael --- On Mon, 6/1/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Missing a "Deriving"? To: haskell-cafe@haskell.org Date: Monday, June 1, 2009, 1:51 PM Am Montag 01 Juni 2009 19:02:36 schrieb michael rice: > All good so far, but then tried t

Re: [Haskell-cafe] Re: Error message reform (was: Strange type errorwith associated type synonyms)

2009-06-01 Thread Claus Reinke
I once thought, that error messages must be configurable by libraries, too. This would be perfect for EDSLs that shall be used by non-Haskellers. Yes, that is a problem. But I have no idea how to design that. There was some work in that direction in the context of the Helium project. See th

Re: [Haskell-cafe] Re: Error message reform

2009-06-01 Thread Claus Reinke
It's too wordy, but it's a start. This is also prime ground for wanting to have configurable levels of error reports, since some users will find it helpful to see both types but others will find it confusing. Indeed. For this simple example, I find Hugs' message nearly optimal, but as one could

Re: [Haskell-cafe] ANN: new version of uu-parsinglib

2009-06-01 Thread S. Doaitse Swierstra
And rename "empty" to "fail"? You managed to confuse me since I always use pSucceed to recognise the empty string. Doaitse On 1 jun 2009, at 01:21, Ross Paterson wrote: On Sun, May 31, 2009 at 09:40:38PM +0200, S. Doaitse Swierstra wrote: A new version of the uu-parsinglib has been uploade

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-06-01 Thread Claus Reinke
Do you argue that overloading logical operations like this in Haskell sacrifices type safety? Could programs "go wrong" [1] that use such abstractions? If I understand your point correctly, you are suggesting that such programs are still type safe. I agree with the claim that such features are

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread Daniel Fischer
Am Montag 01 Juni 2009 19:02:36 schrieb michael rice: > All good so far, but then tried to convert Failable from Computation to > Monad > > > instance Monad Failable where >     return = Success >     fail = Fail >     >>= (Success x) f = f x >     >>= (Fail s) _ = Fail s >     mplus (Fail _) y =

[Haskell-cafe] MySQL, CouchDB, and Haskell

2009-06-01 Thread Henry Laxen
Dear Group, I've spent the last few days trying to convert a bunch of mysql tables into couchdb using haskell, and I've documented my efforts, in case anyone else intends to wander in similar waters. The tutorial is at: http://maztravel.com/haskell/mySqlToCouchDB.html comments welcome here at t

Re: [Haskell-cafe] How to implement this? A case for scoped record labels?

2009-06-01 Thread Brent Yorgey
On Sun, May 31, 2009 at 06:20:23PM -0700, Iavor Diatchki wrote: > > and so on. It is a bit verbose, but you only have to do it once for > your protocol, and then you get the nice overloaded interface. This also seems like the kind of thing perfectly suited to Template Haskell. Especially if the

Re: [Haskell-cafe] Missing a "Deriving"?

2009-06-01 Thread michael rice
I went back and tried to convert the YAHT example to Monad, importing Monad, commenting out all but the data descriptions and the searchAll function, and finally replacing success, failure, augment, and combine in the searchAll function with return, fail, >>=, and mplus. *Main> let g = Graph [(

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-06-01 Thread Jason Dagit
On Mon, Jun 1, 2009 at 3:06 AM, Sebastian Fischer < s...@informatik.uni-kiel.de> wrote: > On Jun 1, 2009, at 12:17 AM, Henning Thielemann wrote: > > On Thu, 28 May 2009, Bulat Ziganshin wrote: >> >> i use another approach which imho is somewhat closer to interpretation >>> of logical operations

Re: [Haskell-cafe] Trouble with types

2009-06-01 Thread Daniel Fischer
Am Montag 01 Juni 2009 14:44:37 schrieb Vladimir Reshetnikov: > Hi, > > I tried this code: > > --- > f, g :: a -> a > (f, g) = (id, id) > --- > > Hugs: OK > > GHC: > Couldn't match expected type `forall a. a -> a' >against inferred type `a ->

[Haskell-cafe] Trouble with types

2009-06-01 Thread Vladimir Reshetnikov
Hi, I tried this code: --- f, g :: a -> a (f, g) = (id, id) --- Hugs: OK GHC: Couldn't match expected type `forall a. a -> a' against inferred type `a -> a' In the expression: id In the expression: (id, id) In a pattern binding:

Re: [Haskell-cafe] GUI and background processing

2009-06-01 Thread Bulat Ziganshin
Hello Dmitry, Monday, June 1, 2009, 4:24:36 PM, you wrote: > All network operations are run in separate thread, but sometimes input > from user is needed. Afaik, gtk2hs is not thread safe, so I came up with look for postGUISync and postGUIASync -- Best regards, Bulat

[Haskell-cafe] GUI and background processing

2009-06-01 Thread Dmitry V'yal
Greetings, fellow haskellers. Currently I'm writing some kind of web crawler in haskell with gtk2hs gui. All network operations are run in separate thread, but sometimes input from user is needed. Afaik, gtk2hs is not thread safe, so I came up with following: I create two mvars, A and B, one

[Haskell-cafe] RE: iota

2009-06-01 Thread Paul Keir
That is quite spectacular. I revised my knowledge of sequence with a little function, akin to "sequence [xs1,xs2]": seq2 xs1 xs2 = do x1 <- xs1 x2 <- xs2 return [x1,x2] > seq2 [0,1] [0,1,2] > [[0,0],[0,1],[0,2],[1,0

Re: [Haskell-cafe] iota

2009-06-01 Thread Raynor Vliegendhart
The iota function you're looking for can be a whole lot simpler if you know about monads (list monad in particular) and sequence. For lists, sequence has the following behaviour: sequence [xs1,xs2, ... xsn] = [[x1,x2, ... , xn] | x1 <- xs1, x2 <- xs2, ... , xn <- xsn] Using this, you can red

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-06-01 Thread Sebastian Fischer
On Jun 1, 2009, at 12:17 AM, Henning Thielemann wrote: On Thu, 28 May 2009, Bulat Ziganshin wrote: i use another approach which imho is somewhat closer to interpretation of logical operations in dynamic languages (lua, ruby, perl): [...] The absence of such interpretations and thus the inc

[Haskell-cafe] problem with inf-haskell + ghci?

2009-06-01 Thread Alex Ott
Hello all I recently found strange problem in use of inf-haskell + ghci on my Mac OS X Tyger. I haven't used inf-haskell for a some time, and several days ago i found, that it stopped to work - when I run C-c C-l (load file) it signal error, and when I perform C-c C-b (start interpreter) it load

[Haskell-cafe] iota

2009-06-01 Thread Paul Keir
Hi all, I was looking for an APL-style "iota" function for array indices. I noticed "range" from Data.Ix which, with a zero for the lower bound (here (0,0)), gives the values I need: > let (a,b) = (2,3) > index ((0,0),(a-1,b-1)) > [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)] However, I nee

Re[2]: [Haskell-cafe] Umlauts in command line arguments

2009-06-01 Thread Bulat Ziganshin
Hello Gwern, Monday, June 1, 2009, 4:35:25 AM, you wrote: > GHC mangles UTF by default. You probably want to use one of the utf8 > packages; eg. > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string > or > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-light >