Hi,
Do I ALWAYS need to create a new instance if I want to modify the state of
an instance? For example, if I design an index for a simple database with an
recursive algebric Tree type, do I need to recreate the whole Tree if I
insert or remove an element? How can I improve performance, what are
On Tue, 2 Oct 2001, Cagdas Ozgenc wrote:
> Do I ALWAYS need to create a new instance if I want to modify the state of
> an instance? For example, if I design an index for a simple database with an
> recursive algebric Tree type, do I need to recreate the whole Tree if I
> insert or remove an elem
It seems like an appropriate page for aske newbie questions, isnt it?
I was reading through Haskell tutroial
(http://www.di.uminho.pt/afp98/PAPERS/Tutorial.ps) and trying to do
exercises from there. I'm stuck in the first exercise for "Classes" chapter
(page 11). I need to define SetsAsLists as
> data Foo = Foo { a :: Int, b :: String }
>
> instance Show Foo where
> show f = show (a f) ++ " " ++ show (b f)
>
> foo = Foo { a = 99, b = "green bottles\n" }
>
> main = do print foo
> let bar = foo { a = 98 }
> print bar
The above code is from Haskell FAQ. I c
"Cagdas Ozgenc" <[EMAIL PROTECTED]> writes:
> Could you help me on this notation?
Perhaps?
>> data Foo = Foo { a :: Int, b :: String }
This declares a Foo constructor with two named fields, and Int "a" and
a String "b". This is equivalent to declaring
data Foo = Foo Int String
but w
Dmitry Astapov wrote (on 02-10-01 15:16 +0300):
>
> It seems like an appropriate page for aske newbie questions, isnt it?
>
> I was reading through Haskell tutroial
> (http://www.di.uminho.pt/afp98/PAPERS/Tutorial.ps) and trying to do
> exercises from there. I'm stuck in the first exercise for "
Dmitry Astapov wrote (on 02-10-01 15:16 +0300):
> union (SL []) (SL ys) = SL ys
> union (SL (x:xs)) (SL ys) | member x (SL ys) = union (SL xs) (SL (x:ys))
> | otherwise= union (SL xs) (SL ys)
I take it back: your implementation has a small problem in
02 Oct 2001 15:16:27 +0300, Dmitry Astapov <[EMAIL PROTECTED]> pisze:
> I need to define SetsAsLists as an instance of Set by supplying
> definitions for all Set methods, but definitions I wrote led me to
> adding additional constraints on "union" and "memeber" methods.
What constraints? The cla