Re: [Haskell-cafe] parser

2007-12-07 Thread Brent Yorgey
On Dec 7, 2007 6:04 PM, Chris Eidhof <[EMAIL PROTECTED]> wrote: > On 7 dec 2007, at 23:51, Ryan Bloor wrote: > > i am using hugs and the isDigit and anything 'is' doesn't work... > > they must have forgot to add them in! Does GHC work with them. > Perhaps you need to import Data.Char? -Brent ___

[Haskell-cafe] Re: Point and link

2007-12-07 Thread Tom Davies
Andrew Coppin btinternet.com> writes: [snip] You might like to look at OpenQuark: http://labs.businessobjects.com/cal/ -- its 'GemCutter' provides a visual environment for linking together functions written in a Haskell-like language. I'm not sure if it would be flexible enough for you out of

Re: [Haskell-cafe] parser

2007-12-07 Thread Chris Eidhof
On 7 dec 2007, at 23:51, Ryan Bloor wrote: i am using hugs and the isDigit and anything 'is' doesn't work... they must have forgot to add them in! Does GHC work with them. Yes, it's in base. Alternatively, you could write the functions yourself, they're not that hard. p.s... that book looks fa

Re: [Haskell-cafe] Literate HTML

2007-12-07 Thread Duncan Coutts
On Fri, 2007-12-07 at 19:14 +, Neil Mitchell wrote: > Hi Brandon, > > > You could replace the "unlit" executable in the GHC library directory > > with one which knows how to extract Haskell code from HTML. > > I want a solution so that I can write the tagsoup manual in an way > that can actu

Re: [Haskell-cafe] parser

2007-12-07 Thread Chris Eidhof
On 7 dec 2007, at 22:55, Ryan Bloor wrote: hi The thing is... it will be a simple parser really. The expressions are already defined and we can't use parsec imports. Below is the types I have. I have a function that removes initial spaces from the start of a string. A function that check

Re: [Haskell-cafe] fundeps and overlapping/undecidable instances

2007-12-07 Thread Jeff Polakow
Hello, Does the following code work for you? -Jeff --- {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fallow-overlapping-instances #-} data Nil = Nil data x ::: xs = x ::: xs infixr 5 ::: data HTrue = HTrue deriving Show data HFalse = HFalse deriving S

Re: [Haskell-cafe] parser

2007-12-07 Thread Chris Eidhof
On 6 dec 2007, at 18:06, Ryan Bloor wrote: Can anyone advise me on how to check whether a string contains ints, chars, bools, etc "2345 + 6767" shoudl give IntAdd (2345) (6767) "2345" should give IntT 2345 You need to write a parser. There are a lot of libraries that will help you write

Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-07 Thread Philipp N.
oleg-7 wrote: > > > In fact, that distinction is possible. The following article > > How to write an instance for not-a-function > http://okmij.org/ftp/Haskell/typecast.html#is-function-type > > specifically describes a method of writing an instance which is > selected only when t

Re: [Haskell-cafe] fundeps and overlapping/undecidable instances

2007-12-07 Thread jim burton
On Fri, 2007-12-07 at 12:49 -0500, Jeff Polakow wrote: > > Hello, > > You should be able to use fundeps to do exactly what you describe > below. > > Can you make a relatively small self-contained example which > exemplifies the ugliness you see? > Hi Jeff, as well as a minor code explosi

Re: [Haskell-cafe] Why is this strict in its arguments?

2007-12-07 Thread Henning Thielemann
On Fri, 7 Dec 2007, Andrew Coppin wrote: > Ian Lynagh wrote: > > On Tue, Dec 04, 2007 at 03:07:01PM -0800, Ryan Ingram wrote: > > > >> Is there a reason why strictness is defined as > >> > >>> f _|_ = _|_ > >>> > >> instead of, for example, > >> > >>> forall x :: Exception. f (throw x) = throw x

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Luke Palmer
On Dec 7, 2007 8:39 PM, Dan Weston <[EMAIL PROTECTED]> wrote: > > compose f g = f . g > > > > compose' f g x = f (g x) > > > > Are you saying that these two exactly equivalent functions should have > > different arity? If not, then is the arity 2 or 3? > > Prelude> :t let compose f g = f . g in c

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Dan Weston
Luke Palmer wrote: On Dec 7, 2007 7:57 PM, Luke Palmer <[EMAIL PROTECTED]> wrote: On Dec 7, 2007 7:41 PM, Dan Weston <[EMAIL PROTECTED]> wrote: Luke Palmer wrote: You can project the compile time numbers into runtime ones: Yes, that works well if I know a priori what the arity of the function

Re: [Haskell-cafe] Why is this strict in its arguments?

2007-12-07 Thread Andrew Coppin
Ian Lynagh wrote: On Tue, Dec 04, 2007 at 03:07:01PM -0800, Ryan Ingram wrote: Is there a reason why strictness is defined as f _|_ = _|_ instead of, for example, forall x :: Exception. f (throw x) = throw x There's discussion along these lines in http://hackage.h

Re: [Haskell-cafe] Point and link

2007-12-07 Thread Claude Heiland-Allen
Denis Bueno wrote: On Dec 7, 2007 1:50 PM, Andrew Coppin <[EMAIL PROTECTED]> wrote: Hi guys. Here's a fairly basic question. I have several ideas for programs that I'd like to write. They all involve placing "units" of some kind, and then drawing "connections" between those units. How feasible

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Luke Palmer
On Dec 7, 2007 7:57 PM, Luke Palmer <[EMAIL PROTECTED]> wrote: > On Dec 7, 2007 7:41 PM, Dan Weston <[EMAIL PROTECTED]> wrote: > > Luke Palmer wrote: > > > You can project the compile time numbers into runtime ones: > > > > Yes, that works well if I know a priori what the arity of the function > >

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Luke Palmer
On Dec 7, 2007 7:41 PM, Dan Weston <[EMAIL PROTECTED]> wrote: > Luke Palmer wrote: > > You can project the compile time numbers into runtime ones: > > Yes, that works well if I know a priori what the arity of the function > is. But I want to be able to have the compiler deduce the arity of the > fu

Re: [Haskell-cafe] Literate HTML

2007-12-07 Thread Brandon S. Allbery KF8NH
On Dec 7, 2007, at 14:14 , Neil Mitchell wrote: You could replace the "unlit" executable in the GHC library directory with one which knows how to extract Haskell code from HTML. I want a solution so that I can write the tagsoup manual in an way that can actually be run - I'd rather not force

Re: [Haskell-cafe] Literate HTML

2007-12-07 Thread Richard Kelsall
Neil Mitchell wrote: ... foo = 1 \end{code} I can then hide the trailing \end{code} with a margin-bottm: -2em. Does anyone have any other ideas? I haven't thought this through, but maybe you could hide the trailing bit by : -- Richard. ___ Ha

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Dan Weston
Luke Palmer wrote: You can project the compile time numbers into runtime ones: Yes, that works well if I know a priori what the arity of the function is. But I want to be able to have the compiler deduce the arity of the function (e.g. by applying undefined until it is no longer a function),

Re: [Haskell-cafe] Literate HTML

2007-12-07 Thread Henning Thielemann
On Fri, 7 Dec 2007, Neil Mitchell wrote: > Hi > > I want literate Haskell, but where the literate bit forming a document > is actually HTML, not latex. Does anyone have any idea how to go about > this? The numeric-quest library was the first and only one that I have seen in this style. I could o

Re: [Haskell-cafe] Point and link

2007-12-07 Thread Denis Bueno
On Dec 7, 2007 1:50 PM, Andrew Coppin <[EMAIL PROTECTED]> wrote: > Hi guys. > > Here's a fairly basic question. I have several ideas for programs that > I'd like to write. They all involve placing "units" of some kind, and > then drawing "connections" between those units. How feasible is it to > pr

Re: [Haskell-cafe] Literate HTML

2007-12-07 Thread Neil Mitchell
Hi Brandon, > You could replace the "unlit" executable in the GHC library directory > with one which knows how to extract Haskell code from HTML. I want a solution so that I can write the tagsoup manual in an way that can actually be run - I'd rather not force any additional dependence on a custo

Re: [Haskell-cafe] Literate HTML

2007-12-07 Thread Brandon S. Allbery KF8NH
On Dec 7, 2007, at 14:07 , Neil Mitchell wrote: I want literate Haskell, but where the literate bit forming a document is actually HTML, not latex. Does anyone have any idea how to go about this? You could replace the "unlit" executable in the GHC library directory with one which knows how

[Haskell-cafe] Literate HTML

2007-12-07 Thread Neil Mitchell
Hi I want literate Haskell, but where the literate bit forming a document is actually HTML, not latex. Does anyone have any idea how to go about this? For a start, how do I persuade GHC to run the file: C:\Documents\Uni\tagsoup>runhaskell index.html Warning: ignoring unrecognised input `index.ht

[Haskell-cafe] Point and link

2007-12-07 Thread Andrew Coppin
Hi guys. Here's a fairly basic question. I have several ideas for programs that I'd like to write. They all involve placing "units" of some kind, and then drawing "connections" between those units. How feasible is it to program such a thing in Haskell? Where would you start? (Gtk2hs is the on

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Benja Fallenstein
On Dec 7, 2007 6:57 PM, Peter Padawitz <[EMAIL PROTECTED]> wrote: > Jules Bean wrote: > > Peter Padawitz wrote: > >> Cause I don't see why the instantiation conflicts pointed out by > >> others would vanish then. > > > > They would. > > > > If it's really true that there is only one possible choice

Re: [Haskell-cafe] ANN: Shu-thing 1.0 and Monadius 0.9

2007-12-07 Thread Andrew Coppin
Bit Connor wrote: Hi, Monadius is awesome! I've made a video of me playing it and kicking some serious ass: http://www.youtube.com/watch?v=zqFgQiPKtOI No way! Hax!! You edited the source code, didn't you? ;-) ___ Haskell-Cafe mailing list Haske

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Luke Palmer
On Dec 7, 2007 6:21 PM, Dan Weston <[EMAIL PROTECTED]> wrote: > This is great! Two questions: > > 1) I want to make sure the function arity matches the list length (as a > runtime check). I think I can do this with an arity function using > Data.Typeable. I came up with: > > arity f = a (typeOf f)

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Jules Bean
Peter Padawitz wrote: So the fundep would solve the problem. But, actually, it doesn't :-( But actually, it does! Ben Franksen's answer from yesterday compiles fine for me if I add the missing fundep, block -> command. Your original code compiles without error, given the fundep. Exact cod

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Luke Palmer
On Dec 7, 2007 5:57 PM, Peter Padawitz <[EMAIL PROTECTED]> wrote: > type Block = [Command] > data Command = Skip | Assign String IntE | Cond BoolE Block Block | Loop > BoolE Block > data IntE= IntE Int | Var String | Sub IntE IntE | Sum [IntE] | Prod > [IntE] > data BoolE = BoolE Bool | Gre

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Dan Weston
This is great! Two questions: 1) I want to make sure the function arity matches the list length (as a runtime check). I think I can do this with an arity function using Data.Typeable. I came up with: arity f = a (typeOf f) where a tr | typeRepTyCon tr /= mkTyCon "->" = 0 | otherwise

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: Jules Bean wrote: Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! Cause I don't see why the instantiation conflicts point

Re: [Haskell-cafe] fundeps and overlapping/undecidable instances

2007-12-07 Thread Jeff Polakow
Hello, You should be able to use fundeps to do exactly what you describe below. Can you make a relatively small self-contained example which exemplifies the ugliness you see? -Jeff [EMAIL PROTECTED] wrote on 12/07/2007 11:24:35 AM: > > I have some type-level sets using fundeps workin

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! Cause I don't see why the instantiation conflicts pointed out by others would vanish then. I'm not

[Haskell-cafe] fundeps and overlapping/undecidable instances

2007-12-07 Thread Jim Burton
I have some type-level sets using fundeps working whereby equality and membership etc are predicate functions. This seems to leads to an explosion of ugly code, with `If' class constraints etc getting out of hand -- I want to treat these as relations instead so providing the definition describes e

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Jules Bean
Peter Padawitz wrote: Jules Bean wrote: Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! Cause I don't see why the instantiation conflicts pointed out by others would

[Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-07 Thread Vimal
Hi, I am working on a product to analyze posts made in Forums, Usenet and discussion mailing lists like Haskell-Cafe. For this, I require the messages to be accessible in this format: (* example: Haskell-cafe *) [ list of - [ list of - ] ] as XML. However, I find that

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Victor Nazarov
On Dec 7, 2007 4:46 PM, Luke Palmer <[EMAIL PROTECTED]> wrote: > On Dec 7, 2007 6:27 AM, Victor Nazarov <[EMAIL PROTECTED]> wrote: > > > > nary 0 x [] = x > > nary n f (x:xs) | n > 0 = nary (n-1) (f $ read x) xs > > Sometimes it helps to write type signatures for functions. As in this > case, wher

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Luke Palmer
On Dec 7, 2007 6:27 AM, Victor Nazarov <[EMAIL PROTECTED]> wrote: > Cool solution and not so complicated and ad-hoc. But I'd like to ask > isn't the following definition is more natural and simple? > > nary 0 x [] = x > nary n f (x:xs) | n > 0 = nary (n-1) (f $ read x) xs Sometimes it helps to wri

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Victor Nazarov
On Dec 7, 2007 2:52 PM, <[EMAIL PROTECTED]> wrote: > > In fact, that distinction is possible. The following article > > How to write an instance for not-a-function > http://okmij.org/ftp/Haskell/typecast.html#is-function-type > > specifically describes a method of writing an instan

[Haskell-cafe] group-by (Was: Nested guards?)

2007-12-07 Thread Henning Thielemann
On Fri, 7 Dec 2007, Simon Peyton-Jones wrote: > | And I think that the solution is not to make the language larger and larger > | everytime someone wants a feature but to give people the tools to provide > | features without language changes. > > Of course that would be even better! (Provided of

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Jules Bean
Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! I'm not sure why a complete cyclic dep a -> b -> c -> d -> a isn't what you want. What seems to be needed here is a type

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Peter Padawitz
Functional dependencies don't work in my case. Actually, I don't see why they should. What seems to be needed here is a type class construct with a kind of record parameter so that instance conflicts cannot occur. Jules Bean wrote: Ben Franksen wrote: Ryan Ingram wrote: On 12/5/07, Ben

[Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread oleg
Philipp N. wrote: > i'm trying to wrap functions (a -> b -> ... -> z) of any arity to functions > of type ([String] -> y), where list of strings replaces the typed arguments. > the problem is, that you cannot distinguish type (x->y) from z, so these > instances are overlapping. to which apfelmus

[Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread apfelmus
Philipp N. wrote: i'm trying to wrap functions (a -> b -> ... -> z) of any arity to functions of type ([String] -> y), where list of strings replaces the typed arguments. one attempt looks like this (here written with type families, you can replace it by functional dependencies or what ever):

[Haskell-cafe] RE: [Haskell] Nested guards?

2007-12-07 Thread Simon Peyton-Jones
| And I think that the solution is not to make the language larger and larger | everytime someone wants a feature but to give people the tools to provide | features without language changes. Of course that would be even better! (Provided of course the resulting programs were comprehensible.) Ha