Re: [Haskell-cafe] algorithm-for-finding-numerical-permutation-given-lexicographic-index

2013-04-03 Thread Tom Davie
efficient, because you're using lists, and attempting to index into them and measure their lengths. Perhaps a different data structure is in order. Thanks Tom Davie On 3 Apr 2013, at 17:38, Lone Wolf amslonew...@gmail.com wrote: http://stackoverflow.com/questions/8940470/algorithm-for-finding

Re: [Haskell-cafe] 9.3 - (2 * 4.5) = 0.3000000000000007

2013-01-16 Thread Tom Davie
Prelude import Data.Ratio Prelude Data.Ratio 93 % 10 - (2 * 9 % 2) 3 % 10 Floating point sucks, avoid it if you can. Thanks Tom Davie On 16 Jan 2013, at 13:25, ivan dragolov i...@dragolov.net wrote: 9.3 - (2 * 4.5) = 0.3007 I expected 0.3 ? -- Иван Драголов

Re: [Haskell-cafe] Existential Types (I guess)

2010-01-22 Thread Tom Davie
Aside from Neil's point about rank-2 polymorphism, you can of course just parameterise your NumHolder type... data Num a = NumHolder a = NumHolder a instance Show a = Show NumHolder a where show (NumHolder x) = show x instance Functor NumHolder where fmap f (NumHolder a) = NumHolder (f a)

Re: [Haskell-cafe] semantics of type synonym

2009-12-29 Thread Tom Davie
On Tue, Dec 29, 2009 at 2:47 PM, pbrowne patrick.bro...@comp.dit.ie wrote: Hi, I am studying the underlying semantics behind Haskell and to what degree those semantics are actually implemented. I need to clarify what a *type synonym* actual means in relation to Haskell's logic (or formal

Re: [Haskell-cafe] Generating AST using Parsec

2009-12-27 Thread Tom Davie
This isn't quite what you're asking for, but by using the applicative interface to parsers, you need do little more than spell out what your AST looks like: import Control.Applicative import Control.Applicative.Infix data Equation = String :=: Expression data Expression = EApp fun arg | EInt Int

Re: [Haskell-cafe] Lazy evaluation/functions

2009-12-27 Thread Tom Davie
Lazy evaluation is an evaluation strategy that gives non-strict semantics. A lazy function I'm not sure how to define. It may be lazy language meaning a function which is non-strict in one of it's arguments. Bob On Sun, Dec 27, 2009 at 1:16 PM, michael rice nowg...@yahoo.com wrote: I've seen

Re: [Haskell-cafe] Re: Why?

2009-12-10 Thread Tom Davie
Non-strictness is not necessary for purity, but it sure gives you some nice properties... Take for example const x y = x It would be really nice for this function to have the property always results in x no matter what you give it as it's second argument. But for a language which is strict, all

Re: [Haskell-cafe] Haskell job opportunity

2009-12-09 Thread Tom Davie
I have to admit, it's just one criterion too much for me. I can manage to satisfy all of them except for willing to work in Manhattan. Bob On Tue, Dec 8, 2009 at 5:54 PM, Tom Tobin korp...@korpios.com wrote: On Tue, Dec 8, 2009 at 11:09 AM, siki ga...@karamaan.com wrote: I've posted this

Re: [Haskell-cafe] Re: Applicative but not Monad

2009-10-31 Thread Tom Davie
On 10/31/09, Heinrich Apfelmus apfel...@quantentunnel.de wrote: The only possible monad instance would be return x = Const mempty fmap f (Const b) = Const b join (Const b) = Const b Your join doesn't seem to have the right type... Unless I'm missing something. Bob

Re: [Haskell-cafe] How to fulfill the code-reuse destiny of OOP?

2009-10-31 Thread Tom Davie
On 10/31/09, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: After all, I never think OO as an oppsite way to all other things. The idea is so general that if you say I cannot use it in Haskell at all, that would make me feel weird. The only difference between languages is, some are

Re: [Haskell-cafe] Applicative but not Monad

2009-10-30 Thread Tom Davie
Of note, there is a sensible monad instance for zip lists which I *think* agrees with the Applicative one, I don't know why they're not monads: instance Monad (ZipList a) where return = Ziplist . return join (ZipList []) = ZipList [] join (ZipList (a:as)) = zlHead a `zlCons` join (map

Re: [Haskell-cafe] Applicative but not Monad

2009-10-30 Thread Tom Davie
On Fri, Oct 30, 2009 at 5:59 PM, Luke Palmer lrpal...@gmail.com wrote: On Fri, Oct 30, 2009 at 10:39 AM, Tom Davie tom.da...@gmail.com wrote: Of note, there is a sensible monad instance for zip lists which I *think* agrees with the Applicative one, I don't know why they're not monads

Re: [Haskell-cafe] GHC and OS X (10.4) [SOLVED]

2004-09-28 Thread Tom Davie
to install ghc and it's dependancies. Hope this helps anyone digging in the archives for a solution. Tom Davie On Thu, 2 Sep 2004 22:59:59 -0400, Gregory Wright [EMAIL PROTECTED] wrote: Hi Tom, You might try building ghc using darwinports (darwinports.opendarwin.org). It works under both