Why?
real numbers, complex nuimbers, n-dimensional spaces have well defined + and
* operations (vectorial product in the latter case).
even algebraic expressions like:
data Expr = Var String | Number Integer | Sin Expr | Cos Expr
can be instances of Num and express certain simplification rules
Soenke Hahn schrieb:
> If you want to use number literals, you have to implement an instance for
> Algebra.Ring.C, if i understand correctly. Is there any special reason, why
> fromInteger is a method of Algebra.Ring.C?
Yes, Ring is the most basic class in the hierarchy that provides a zero,
a
On Oct 6, 2009, at 3:49 AM, Lennart Augustsson wrote:
But complex numbers are just pairs of numbers. So pairs of numbers
can obviously be numbers then.
The basic problem here is that pairs of numbers can be made
to fit into the Haskell framework with more than one semantics.
For example, hi
On Monday 05 October 2009 11:58:28 pm Henning Thielemann wrote:
> On Mon, 5 Oct 2009, Soenke Hahn wrote:
> > On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote:
> >> I use NumericPrelude that has more fine grained type classes. E.g. (+)
> >> is in Additive and (*) is in Ring.
> >>
> >>
On Mon, 5 Oct 2009, Soenke Hahn wrote:
On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote:
I use NumericPrelude that has more fine grained type classes. E.g. (+)
is in Additive and (*) is in Ring.
http://hackage.haskell.org/package/numeric-prelude
That is pretty cool, thanks.
On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote:
> Sönke Hahn schrieb:
> > Hi!
> >
> > I often stumble upon 2- (or 3-) dimensional numerical data types like
> >
> > (Double, Double)
> >
> > or similar self defined ones. I like the idea of creating instances for
> > Num for these
Sönke Hahn schrieb:
> Hi!
>
> I often stumble upon 2- (or 3-) dimensional numerical data types like
>
> (Double, Double)
>
> or similar self defined ones. I like the idea of creating instances for Num
> for
> these types. The meaning of (+), (-) and negate is clear and very intuitive,
> i
On 5 Oct 2009, at 19:17, Lennart Augustsson wrote:
Complex numbers are just pairs of numbers,
What about dual numbers? (Yes, I've remembered the term) Aren't they
also just pairs of numbers?
There may be other ways to define the operations on pairs of numbers
that makes sense too.
But
Complex numbers are just pairs of numbers, and then the various
operations on them are defined in a specific way.
There may be other ways to define the operations on pairs of numbers
that makes sense too.
You can also view complex numbers as polynomials if you wish. Or two
element lists of number
Lennart Augustsson wrote:
Everyone agrees that the Haskell numeric hierarchy is flawed, but I've
yet to see a good replacement.
That's because the "good replacement" which is mathematically sound
would be a real mess to work with -- for exactly the same reason that
Functor , Applicative and
Shouldn't the question not be "Is this a number?" but rather "What is
a number?" -- I mean, from an abstract point of view, there's really
no such thing, right? We have sets of things which we define an
operation that has certain properties, and suddenly we start calling
them numbers. Are t
Am Montag 05 Oktober 2009 16:29:02 schrieb Job Vranish:
> In what way is it not a number?
>
If there's a natural[1] implementation of fromInteger, good.
If there isn't, *don't provide one*.
fromInteger _ = error "Not sensible" is better than doing something strange.
[1] In the case of residue cl
No, they aren't. They are polynomials in one variable "i" modulo i^2+1.
Seriously, if you say complex numbers are just pairs of real numbers -
you have to agree that double numbers (sorry, don't know the exact
English term), defined by
(a,b)+(c,d) = (a+c,b+d)
(a,b)(c,d) = (ac, ad+bc)
are jus
Everyone agrees that the Haskell numeric hierarchy is flawed, but I've
yet to see a good replacement.
On Mon, Oct 5, 2009 at 4:51 PM, Brad Larsen wrote:
> On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov
> wrote:
> [...]
>> Of course, it's OK to call anything "numbers" provided that you stated
On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov
wrote:
[...]
> Of course, it's OK to call anything "numbers" provided that you stated
> explicitly what exactly you would mean by that. But then you have to drop
> all kind of stuff mathematicians developed for the usual notion of numbers.
> In th
But complex numbers are just pairs of numbers. So pairs of numbers
can obviously be numbers then.
On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov wrote:
> Lennart Augustsson wrote:
>>
>> And what is a number?
>
> Can't say. You know, it's kinda funny to ask a biologist what it means to be
> al
Lennart Augustsson wrote:
And what is a number?
Can't say. You know, it's kinda funny to ask a biologist what it means
to be alive.
Are complex numbers numbers?
Beyond any reasonable doubt. Just like you and me are most certainly alive.
___
Hask
Miguel Mitrofanov, please kindly stop pretending that you KNOW
what is a number, and what is not.
Never said that. Sometimes it's debatable. But if you can't figure out a
way to multiply things so that it would make some kind of sense - you
haven't made them numbers (yet).
The numeric class
In what way is it not a number?
data MyNumber a = MyNum a a
deriving (Show, Eq)
instance Functor MyNum where
fmap f (MyNum a b) = MyNum (f a) (f b)
instance Applicative MyNum where
pure a = MyNum a a
MyNum f g <*> MyNum a b = MyNum (f a) (g b)
instance (Num a) => Num (MyNum a) where
Miguel Mitrofanov rebukes Sönke Hahn, who -:
wrote:
I used to implement
fromInteger n = (r, r) where r = fromInteger n
, but thinking about it,
fromInteger n = (fromInteger n, 0)
seems very reasonable, too.
Stop pretending something is a number when it's not.
Miguel Mitrofanov,
And what is a number? Are complex numbers numbers?
On Mon, Oct 5, 2009 at 3:12 PM, Miguel Mitrofanov wrote:
>
>
> Sönke Hahn wrote:
>
>> I used to implement
>>
>> fromInteger n = (r, r) where r = fromInteger n
>>
>> , but thinking about it,
>> fromInteger n = (fromInteger n, 0)
>>
>> seems
That's not gonna happen until when/if Haskell supports name/operator
overloading. There's a scarcity of good symbols/function names and
everyone wants to use them. So naturally, type class abuse follows.
Regards,
John A. De Goes
N-Brain, Inc.
The Evolution of Collaboration
http://www.n-br
Sönke Hahn wrote:
I used to implement
fromInteger n = (r, r) where r = fromInteger n
, but thinking about it,
fromInteger n = (fromInteger n, 0)
seems very reasonable, too.
Stop pretending something is a number when it's not.
___
Has
You are in luck!
Such an instance is very simple with Applicative. If the type you want a Num
instance for is a member of the Applicative type class you can define it
like this:
instance (Num a) => Num (Vector2 a) where
a + b = pure (+) <*> a <*> b
a - b = pure (-) <*> a <*> b
a * b = pure
Hi!
I often stumble upon 2- (or 3-) dimensional numerical data types like
(Double, Double)
or similar self defined ones. I like the idea of creating instances for Num for
these types. The meaning of (+), (-) and negate is clear and very intuitive, i
think. I don't feel sure about (*), abs,
25 matches
Mail list logo