Re: [Haskell-cafe] Still having problems building a very simple Executable ....

2009-06-07 Thread Vasili I. Galchin
thanks, David. Vasili On Sun, Jun 7, 2009 at 12:17 AM, David Menendez d...@zednenem.com wrote: On Sat, Jun 6, 2009 at 11:54 PM, Vasili I. Galchin vigalc...@gmail.com wrote: Hi David, I commented out Hs-source-dirs Executable QNameTest -- Hs-source-dirs: Swish/

[Haskell-cafe] Re: Haddock : parse error on input `{-# UNPACK'

2009-06-07 Thread Dominic Steinitz
Erik de Castro Lopo mle+hs at mega-nerd.com writes: Dominic Steinitz wrote: Erik de Castro Lopo mle+hs at mega-nerd.com writes: src/Data/Binary/Strict/IncrementalGet.hs:106:11: parse error on input `{-# UNPACK' This is a haddock error and I presume a bug in

[Haskell-cafe] Re: Haddock : parse error on input `{-# UNPACK'

2009-06-07 Thread Dominic Steinitz
Dominic Steinitz dominic at steinitz.org writes: Erik de Castro Lopo mle+hs at mega-nerd.com writes: Dominic Steinitz wrote: Erik de Castro Lopo mle+hs at mega-nerd.com writes: src/Data/Binary/Strict/IncrementalGet.hs:106:11: parse error on input `{-#

[Haskell-cafe] totally confused about Haskell namespace issue conventions

2009-06-07 Thread Vasili I. Galchin
Hello, Should namespace designation be specified in modules or in the .cabal file? Or to put it another way should a relative namespace be specified in a Haskell module and the remaining top part be specified in the associated .cabal file? Of course, yes/no answers are probably not

[Haskell-cafe] Re: totally confused about Haskell namespace issue conventions

2009-06-07 Thread Vasili I. Galchin
let put this subject in another way ... assuming there a coding convention, vis-a-vis Haskell namespace, what is the division of responsibility between a Haskell module and it's associated .cabal? Regards, Vasili On Sun, Jun 7, 2009 at 2:26 AM, Vasili I. Galchin vigalc...@gmail.comwrote:

Re: [Haskell-cafe] Re: Haddock : parse error on input `{-# UNPACK'

2009-06-07 Thread Erik de Castro Lopo
Dominic Steinitz wrote: -- | The parse state data S = S {-# UNPACK #-} !BL.ByteString -- ^ input {-# UNPACK #-} !Int -- ^ bytes read {-# UNPACK #-} ![B.ByteString] {-# UNPACK #-} !Int -- ^ the failure depth -- | The parse state data S = S {-# UNPACK

[Haskell-cafe] Re: totally confused about Haskell namespace issue conventions

2009-06-07 Thread Vasili I. Galchin
let me state another way as far as namespace is concerned what is division between a module's name and it's associated .cabal with it's Hs-Source-Dirs directive? This is kinda' absolute vs relative path I think. Regards, Vasili On Sun, Jun 7, 2009 at 2:46 AM, Vasili I. Galchin

Re: [Haskell-cafe] Question on rank-N polymorphism

2009-06-07 Thread Vladimir Reshetnikov
Hi Zsolt, fs :: (((a, a) - a) - t) - (t, t) fs g = (g fst, g snd) examples = (fs fmap, fs liftA, fs liftM, fs id, fs ($(1,2)), fs ((,)id), fs (:[]), fs repeat) No instance for (Num [Char]) arising from the literal `1' at M.hs:6:54 Possible fix: add an instance declaration for (Num

Re: [Haskell-cafe] Question on rank-N polymorphism

2009-06-07 Thread Ryan Ingram
This is a really interesting question. So, fs is well-typed in Haskell: fs :: (((a,a) - a) - t) - (t,t) i.e. fs id :: ((a,a) - a, (a,a) - a) However, I believe what you are asking is for fs to be equivalent to the following: fs2 f g = (f fst, g snd) which has the type fs2 :: (((a, b) -

Re: [Haskell-cafe] totally confused about Haskell namespace issue conventions

2009-06-07 Thread Magnus Therning
Vasili I. Galchin wrote: Hello, Should namespace designation be specified in modules or in the .cabal file? Or to put it another way should a relative namespace be specified in a Haskell module and the remaining top part be specified in the associated .cabal file? Of course, yes/no

[Haskell-cafe] Roman to Decimal Algorithms

2009-06-07 Thread Andrew Savige
I recently played in a code golf Roman to Decimal challenge (in Perl, Python, Ruby and PHP). In playing this game, I found some interesting short algorithms for converting from Roman Numerals to Decimal. Because I think some of these are new, I'd like to present them here, in case they are not

Re: [Haskell-cafe] using phantom types to validate html

2009-06-07 Thread Thomas ten Cate
I have been thinking about this same problem a while ago, and found that HaXml [1] can generate Haskell types from a DTD schema. However, the code that you need to build HTML from that is quite verbose. Being no expert in Haskell, I talked to Twan van Laarhoven, who came up with something [2]

[Haskell-cafe] Re: using phantom types to validate html

2009-06-07 Thread Heinrich Apfelmus
Mathijs Kwik wrote: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2575#a2575 I wanted to use the typesystem to mandate businesslogic (in this case w3c validation rules). You may want to have a look at Peter Thiemann's WASH/HTML

Re: [Haskell-cafe] Question on rank-N polymorphism

2009-06-07 Thread Ryan Ingram
Well, I don't really recommend programming in dependently typed languages right now :) But if you must, Agda has been getting a lot of attention recently. Also, the theorem prover Coq is based on the dependently-typed lambda calculus. In Haskell, giving a function an intersection type is

[Haskell-cafe] Re: totally confused about Haskell namespace issue conventions

2009-06-07 Thread Maurí­cio
as far as namespace is concerned what is division between a module's name and it's associated .cabal with it's Hs-Source-Dirs directive? This is kinda' absolute vs relative path I think. Vasili, First, let's talk about Haskell modules, without mentioning cabal. When Haskell 98 standard came,

Re: [Haskell-cafe] Question on rank-N polymorphism

2009-06-07 Thread Wouter Swierstra
The idea is that fs accepts a polymorphic function as its argument. What type signature can I specify for f in order to compile this code? As you said yourself, you need to add a type signature to fs: {-# LANGUAGE RankNTypes #-} fs :: ((forall a . ((a, a) - a)) - t) - (t, t) fs g = (g

Re: [Haskell-cafe] Roman to Decimal Algorithms

2009-06-07 Thread Tillmann Rendel
Hi Andrew, Andrew Savige wrote: Noticing this, you can replace the 205558`mod`(ord c)`mod`7 magic formula with a function that returns a string index (index() in Perl and Python). I am sometimes overwhelmed by the quantity and richness of all the functions in the GHC Haskell libraries. Have

Re: [Haskell-cafe] comprehension problem

2009-06-07 Thread ptrash
Cool, thanks a lot. Ross Mellgren wrote: P Float is the constructor to create a value of this type, similar to data declarations. That is, 0.5 :: Float, P 0.5 :: Probability The {} notation after D creates a record accessor, also similar to data declarations. It's equivalent to

[Haskell-cafe] Change value of a variable

2009-06-07 Thread ptrash
Hi, how can I change the value of a variable. let x = 1 x = x + 2 First I set the value of x to 1. Then I want to increase it by 2. This way doesn't work, because I think it is a infinite expression. Is there a way to change the value? -- View this message in context:

Re: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Bulat Ziganshin
Hello ptrash, Sunday, June 7, 2009, 9:41:56 PM, you wrote: Hi, how can I change the value of a variable. there are no variables in haskell :))) x, like any other identifier, is a value. when you translate to Haskell some algo that needs to update variable contents, you may either 1) use

Re: [Haskell-cafe] Roman to Decimal Algorithms

2009-06-07 Thread Martijn van Steenbergen
Hi Andrew, I haven't read your whole message but if shortness is your goal, here are some ideas: Andrew Savige wrote: rtoa c = 10^(205558`mod`(ord c)`mod`7)`mod`9995 I'm not suggesting that magic formulae are useful outside of golf and this second rtoa function, though shorter, is much less

Re: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Keith Sheppard
I guess the short answer is that it is not possible. 'x' is immutable and if you want a different value than 'x' that expression has to be given a different name like: let x=1 y=x+2 ... But I'm not sure if that helps you. Haskell does things very differently than the imperative languages

Re[2]: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Bulat Ziganshin
Hello ptrash, Sunday, June 7, 2009, 11:03:55 PM, you wrote: Hi, thanks for the answers. I want to make something like a counter. I have written a recursive method which for example runs x times and counts how many times it runs, and also count some other thinks. Add the end I want a

Re: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Deniz Dogan
2009/6/7 ptrash ptr...@web.de: Hi, thanks for the answers. I want to make something like a counter. I have written a recursive method which for example runs x times and counts how many times it runs, and also count some other thinks. Add the end I want a statistic about certain thinks

Re: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Ketil Malde
ptrash ptr...@web.de writes: I want to make something like a counter. I have written a recursive method which for example runs x times and counts how many times it runs, and also count some other thinks. Add the end I want a statistic about certain thinks returned by the method. Keep in mind

[Haskell-cafe] Random Number

2009-06-07 Thread ptrash
Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something like let randomNumber = random 1 30 to get a random number between 1 and 30. -- View this message in context:

Re: [Haskell-cafe] Change value of a variable

2009-06-07 Thread ptrash
What i am exactly to do is this: I have a list of pupils (type Pupil = (Name, Grade)) where I store the name of the pupil and which grade he has. No I want to get the number (and average number) of each grade. Something like 10 Pupils have a A (23%), 2 Pupils have a B ( 4 %) etc -- View this

Re: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Jeff Heard
Sounds like a fold to me. Try looking at the doc of either foldl/r/l' or mapAccum depending on what you want.. Then write a function for one iteration that returns the value from that iteration combined with the value from the last iteration -- Jeff On Sun, Jun 7, 2009 at 3:44 PM,

Re: [Haskell-cafe] Random Number

2009-06-07 Thread José Prous
look in System.Random randomRIO :: (Random a) = (a, a) - IO a you can do randomNumber-randomRIO (1,30) On Sun, Jun 7, 2009 at 3:33 PM, ptrash ptr...@web.de wrote: Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something

Re: [Haskell-cafe] Random Number

2009-06-07 Thread Krzysztof Skrzętnicki
On Sun, Jun 7, 2009 at 21:33, ptrashptr...@web.de wrote: Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something like let randomNumber = random 1 30 to get a random number between 1 and 30. I don't mean to be rude, but

Re: [Haskell-cafe] Question on rank-N polymorphism

2009-06-07 Thread Ryan Ingram
The most interesting example is fs ($ (1, 2)) Which I haven't been able to make typecheck. Here's some well-typed code: fs2 f g = (f fst, g snd) ab f = f ('a', b) test = fs2 ab ab -- test2 = fs ab The question is, is it possible to write fs such that your examples typecheck and test2 also

Re[2]: [Haskell-cafe] Change value of a variable

2009-06-07 Thread Bulat Ziganshin
Hello ptrash, Sunday, June 7, 2009, 11:44:18 PM, you wrote: I have a list of pupils (type Pupil = (Name, Grade)) where I store the name of the pupil and which grade he has. No I want to get the number (and average number) of each grade. Something like 10 Pupils have a A (23%), 2 Pupils have

Re: [Haskell-cafe] Monad transformer responsibilities

2009-06-07 Thread Henning Thielemann
Ryan Ingram schrieb: From what I understand, the current best practices are to build your package dependencies like so: ParsecMyMonadT MyMonadT_Parsec -- orphan instances go here ProjectPackage This does mean splitting up your project into three packages, but decouples the orphan

Re: [Haskell-cafe] Random Number

2009-06-07 Thread Iain Barnett
On 7 Jun 2009, at 8:33 pm, ptrash wrote: Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something like let randomNumber = random 1 30 to get a random number between 1 and 30. rand :: Int - Int - IO Int rand low high =

Re: [Haskell-cafe] Random Number

2009-06-07 Thread michael rice
Good essay. Try this one for a laugh: http://www.mcs.vuw.ac.nz/comp/Publications/CS-TR-02-9.abs.html A good place to begin is PDF pg. 19. Michael --- On Sun, 6/7/09, Krzysztof Skrzętnicki gte...@gmail.com wrote: From: Krzysztof Skrzętnicki gte...@gmail.com Subject: Re: [Haskell-cafe]

Re: [Haskell-cafe] Roman to Decimal Algorithms

2009-06-07 Thread Andrew Savige
Tillmann Rendel wrote: Have you tried hoogle?   http://haskell.org/hoogle/?hoogle=String+-%3E+Maybe+Int This suggests Data.List.elemIndex. Hadn't heard of hoogle before. Will use it from now on though. :) Hoogle's suggestion of Data.List.elemIndex works like a charm. Thanks, /-\

Re: [Haskell-cafe] Roman to Decimal Algorithms

2009-06-07 Thread Andrew Savige
Martijn van Steenbergen wrote: Why not rename mod like so? (%)=mod rtoa c=10^(205558%ord c%7)%9995 Thanks Martijn. My first Haskell golfing tip. :) I found I had to write it with an extra set of parens to get it to work: rtoa c=(10^(205558%ord c)%7)%9995 Though it wasn't my original

[Haskell-cafe] Re: Building network package on Windows

2009-06-07 Thread Iavor Diatchki
Hello, Here is an update, in case anyone else runs into the same problem. My understanding, is that the problem was caused by a mistake in the configure script for the network package, which after (correctly) detecting that IPv6 functionality was not available on my platform, it (incorrectly)

Re: [Haskell-cafe] ghci: can't load .so/.DLL for: m (addDLL: could not load DLL) / is there a libm.dll for Windows

2009-06-07 Thread wren ng thornton
Mark Wassell wrote: Hello, I get this when using the logfloat package via ghci on Windows. For example *Main :m + Data.Number.LogFloat *Main Data.Number.LogFloat logFloat (1.0::Float) Loading package syb ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package

[Haskell-cafe] How to convert DiffTime to a number?

2009-06-07 Thread Magicloud Magiclouds
Hi, Documents said that DiffTime could treat as how many seconds. So how to convert it to a number of seconds? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: How to convert DiffTime to a number?

2009-06-07 Thread Magicloud Magiclouds
Ah, floor $ toRational dt. On Mon, Jun 8, 2009 at 1:09 PM, Magicloud Magicloudsmagicloud.magiclo...@gmail.com wrote: Hi,  Documents said that DiffTime could treat as how many seconds. So how to convert it to a number of seconds? Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 -- 竹密岂妨流水过 山高哪阻野云飞