Re: [Haskell-cafe] (**) over integers

2005-06-14 Thread ajb
G'day all. Quoting Maurício <[EMAIL PROTECTED]>: > but I see that I can't because ** only operates on floats. Is there an > equivalent operator that works on integers? How should I do that? Prelude> :t (**) (**) :: forall a. (Floating a) => a -> a -> a Prelude> :t (^) (^) :: forall a b. (Integra

[Haskell-cafe] (**) over integers

2005-06-14 Thread Maurício
Hi, I'm trying to do this: let f n = mod (n**5) 12 but I see that I can't because ** only operates on floats. Is there an equivalent operator that works on integers? How should I do that? Thanks, Maurício ___ Haskell-Cafe mailing list Hask

Re: [Haskell-cafe] Using type classes for polymorphism of data constructors

2005-06-14 Thread Thomas Sutton
On 13/06/2005, at 8:29 PM, Henning Thielemann wrote: On Sat, 11 Jun 2005, Thomas Sutton wrote: The end goal in all of this is that the user (perhaps a logician rather than a computer scientist) will describe the calculus they wish to use in a simple DSL. This DSL will then be translated into Has

Re[2]: [Haskell-cafe] Garbage collection and finalizer thread priority

2005-06-14 Thread Bulat Ziganshin
Hello Gracjan, Tuesday, June 14, 2005, 4:36:26 PM, you wrote: >> it's an error in GHC 6.4/win32 >> GP> :) GP> How do I take care of that? use `+RTS -M' to increase it. you can include this optiion in executable, so user don't need to specify it each time. see somewhere in GHC docs -- Best reg

Re: [Haskell-cafe] Garbage collection and finalizer thread priority

2005-06-14 Thread Gracjan Polak
Bulat Ziganshin wrote: Hello Gracjan, Tuesday, June 14, 2005, 1:29:09 PM, you wrote: GP> Documentation says: GP> -Msize GP> [Default: unlimited] Set the maximum heap size to size bytes. The GP> heap normally grows and shrinks according to the memory requirements of GP> the program...

Re[2]: [Haskell-cafe] Garbage collection and finalizer thread priority

2005-06-14 Thread Bulat Ziganshin
Hello Gracjan, Tuesday, June 14, 2005, 1:29:09 PM, you wrote: GP> Documentation says: GP> -Msize GP> [Default: unlimited] Set the maximum heap size to size bytes. The GP> heap normally grows and shrinks according to the memory requirements of GP> the program... GP> GHC 6.4 says: GP> Heap

Re: [Haskell-cafe] Garbage collection and finalizer thread priority

2005-06-14 Thread Gracjan Polak
Simon Marlow wrote: On 13 June 2005 11:30, Gracjan Polak wrote: My space problems continued... :) Follow up :) I have some ForeignPtr's, with finalizers (finalizerFree only). And I have lazyly produced list of those (yes, there is some unsafePerformIO magic behind, but I think I got this

Re: [Haskell-cafe] Garbage collection and finalizer thread priority

2005-06-14 Thread Gracjan Polak
Sebastian Sylvan wrote: On 6/13/05, Simon Marlow <[EMAIL PROTECTED]> wrote: I presume you're running GHC. There's no way to increase the priority of a thread - GHC's scheduler doesn't have a concept of priorities. Just out of curiousity, what scheme does GHC use for scheduling threads?

Re: [Haskell-cafe] Re: Generic types

2005-06-14 Thread Cale Gibbard
For extra fun, notice that you can make declarations like: data (Unit u) => Kilo u = Kilo u instance (Unit u) => Unit (Kilo u) where shortName (Kilo u) = "k" ++ shortName u which behaves in ghci like: *Main> UnitValue (Kilo Meter) 30 30km - Cale

Re: [Haskell-cafe] Re: Generic types

2005-06-14 Thread Cale Gibbard
On 14/06/05, Adde <[EMAIL PROTECTED]> wrote: > Cale Gibbard gmail.com> writes: > > > > > Perhaps you want > > data UnitValue u n = > > (Unit u, Num n) => UnitValue {uUnit :: u, uValue :: n} > > > > I tried adding UnitValue as an instance of class Show, but I can't figure out > how to tell t

Re: [Haskell-cafe] Re: Generic types

2005-06-14 Thread Cale Gibbard
On 14/06/05, Adde <[EMAIL PROTECTED]> wrote: > While we're at it, I tried adding a class Length in between Unit and Meter, > like > this: > > class Unit u where > shortName :: u -> String > > class (Unit u) => Length u > > instance Length Meter where > shortName u = "m" > > >From the i

[Haskell-cafe] Re: Generic types

2005-06-14 Thread Adde
> What you want is a technique called "existential types". The wiki page > is here: http://haskell.org/hawiki/ExistentialTypes Thanks, I stumbled upon Existential Types earlier but ofcourse I tried to use them with labeled records. ___ Haskell-Cafe ma

[Haskell-cafe] Re: Generic types

2005-06-14 Thread Adde
While we're at it, I tried adding a class Length in between Unit and Meter, like this: class Unit u where shortName :: u -> String class (Unit u) => Length u instance Length Meter where shortName u = "m" >From the information I can find on the web subclassing should include all of the

[Haskell-cafe] Re: Generic types

2005-06-14 Thread Adde
Cale Gibbard gmail.com> writes: > > Perhaps you want > data UnitValue u n = > (Unit u, Num n) => UnitValue {uUnit :: u, uValue :: n} > I tried adding UnitValue as an instance of class Show, but I can't figure out how to tell the compiler that u is a Unit and m is a Num (shouldn't it be a