Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-06 Thread Jean-Marie Gaillourdet
Hi, On 06.06.2007, at 07:00, Phlex wrote: So here is one more question : Let's say I want unique System names across the Universe ... that would mean i need to have a Data.Map in the Universe, with Name keys and System values. Since all data are values instead of references, would i end

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-05 Thread Phlex
Christopher Lane Hinson wrote: Where InsidenessMap a b c represents a relationship where b's are inside a's, and b's have a state of c. Then, you need to declare a separate InsidenessMap for each possible relationship, but this ensures that you'll never put a galaxy inside a solar system.

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-05 Thread Al Falloon
Phlex wrote: Christopher Lane Hinson wrote: Where InsidenessMap a b c represents a relationship where b's are inside a's, and b's have a state of c. Then, you need to declare a separate InsidenessMap for each possible relationship, but this ensures that you'll never put a galaxy inside a

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-05 Thread apfelmus
Phlex wrote: Ketil Malde wrote: Identity can be emulated by relatively straightforward means: store all planets in a Map indexed by something that is useful as an identifier (i.e. stays constant and is unique), and have a Galaxy keep a list of identifiers. So basically you guys are

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-05 Thread Phlex
apfelmus wrote: Phlex wrote: Ketil Malde wrote: Is the relational model a better fit than the object model for functional programming ? Well, not really. I mean, if the problem is indeed to store all known planets in the universe, then it's indeed a database in nature and you

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread David Menendez
Arie Peterson writes: There are two things one typically wants to do when working with a substructure of some larger data structure: (1) extract the substructure; and (2) change the larger structure by acting on the substructure. A 'Ref cx t' encodes both of these functions (for a

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread Claus Reinke
| data Ref cx t | = Ref | { | select :: cx - t | , update :: (t - t) - cx - cx | } | | A Ref is a bit like a typed and composable incarnation of apfelmus's | indices, or a wrapper around Tillmann's change* functions, containing | not only a setter but also the accompanying

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread Arie Peterson
David Menendez wrote: | That's a neat idiom. I wonder how far one could usefully generalize it. | | For example, | | type Ref cx t = forall f. Functor f = (t - f t) - cx - f cx | | newtype Id a = Id { unId :: a } | instance Functor Id where fmap f = Id . f . unId | | newtype K t a

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread apfelmus
Phlex wrote: Donald Bruce Stewart wrote: Imagine updating a node in a tree by just detaching and reattaching a pointer. [1] [1] / \ / \ [2] [3] update node 5 [2] [3] / \ with value 7 / \ [4] [5]

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Donald Bruce Stewart
apfelmus: Phlex wrote: Donald Bruce Stewart wrote: Imagine updating a node in a tree by just detaching and reattaching a pointer. [1] [1] / \ / \ [2] [3] update node 5 [2] [3] / \ with value 7 / \

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Phlex
apfelmus wrote: Phlex wrote: Donald Bruce Stewart wrote: Yes and no. The point is that if you can't automate it, you have to code it by hand anyway which constitutes most of the hairiness. But I know what you mean and there's a nice way to do that with multi-parameter type classes.

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread apfelmus
apfelmus wrote: {-# OPTIONS_GHC -fglasgow-exts -#} import Prelude hiding (lookup) class Map map key a | map key - a where lookup :: key - map - Maybe a adjust :: (a - a) - key - map - map instance (Map m k m', Map m' k' a) = Map m (k,k') a where

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Christopher Lane Hinson
Let's say i have a deep nested data structure. Universe containing galaxies, containing solar systems, containing planets, containing countries, containing inhabitants, containing ...whatever. Oh. I had /exactly/ this problem. If you use separate types (i.e. a newtyped integer, acting

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Arie Peterson
You could also use 'compositional functional references'. These are introduced in the paper A Functional Programming Technique for Forms in Graphical User Interfaces by Sander Evers, Peter Achten and Jan Kuper. === Introduction === There are two things one typically wants to do when working with

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Stefan O'Rear
(Sorry to break the thread, but mutt somehow managed to eat the message I'm replying to...) Arie Peterson: You could also use 'compositional functional references'. These are introduced in the paper A Functional Programming Technique for Forms in Graphical User Interfaces by Sander Evers,

Re: [Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Neil Mitchell
Hi You could also use 'compositional functional references'. These are introduced in the paper A Functional Programming Technique for Forms in Graphical User Interfaces by Sander Evers, Peter Achten and Jan Kuper. I've written a template haskell function to derive Refs from a data