Hello all,
I'm coming from the OO world, and there's something i don't quite
understand in the way haskellers manipulate data (as all functional
programmers i guess).
Let's say i have a deep nested data structure.
Universe containing galaxies, containing solar systems, containing
planets,
Phlex:
Hello all,
I'm coming from the OO world, and there's something i don't quite
understand in the way haskellers manipulate data (as all functional
programmers i guess).
Let's say i have a deep nested data structure.
Universe containing galaxies, containing solar systems,
Donald Bruce Stewart wrote:
Phlex:
On the other side, using the functional paradigm, it seems to me that
the function i use in order to create a _new_ inhabitant with a
different age will need to have knowledge of the country over it, the
planet ..and so on up to the universe...as i need
Hello Phlex,
Sunday, June 3, 2007, 11:41:29 AM, you wrote:
That's precisely the thing i don't understand.
In order to update node 3 with a new pointer, i need to mutate it, so i
need to recreate it, and so on up to node 1.
yes, that's true
Now in this exemple, it's ok since that's a regular
Bulat Ziganshin wrote:
Hello Phlex,
Sunday, June 3, 2007, 11:41:29 AM, you wrote:
That's precisely the thing i don't understand.
In order to update node 3 with a new pointer, i need to mutate it, so i
need to recreate it, and so on up to node 1.
yes, that's true
Now in this
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]
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 / \
Phlex [EMAIL PROTECTED] writes:
The thing is, now that i have my planet p... i want to change it's age
... and get back the new state of the universe...
It is true, there is often a significant amount of boilerplate code
needed to wrap a simple planet-change nested deep within a universe
Hello Phlex,
Sunday, June 3, 2007, 12:34:26 PM, you wrote:
So i need to do something like this :
changePlanetAge universe galaxy planet age = ...lots of code, returning
a new universe
And the same code for all functions updating any of the properties of my
planet ...
And the same code for
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.
Hello Malcolm,
Sunday, June 3, 2007, 1:13:06 PM, you wrote:
The thing is, now that i have my planet p... i want to change it's age
... and get back the new state of the universe...
There has been lots of research into easing the pain of creating this
outer traversal code - search for Scrap
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
On Sat, 2 Jun 2007, Fritz Ruehr wrote:
I seem to recall that Aarne Ranta ran Hugs on a (Sharp) Zaurus PDA at one of
the ICFPs a few years back. Aha, here in fact is a picture of his GF
(Grammatical Framework), written in Haskell, running on a Zaurus:
I've got Hugs and GHC both running under
Hello,
Phlex wrote:
changePlanetAge universe galaxy planet age = ...lots of code, returning
a new universe
And the same code for all functions updating any of the properties of my
planet ...
And the same code for all functions updating properties of a country on
this planet...
In functional
Tillmann Rendel wrote:
Hello,
Phlex wrote:
changePlanetAge universe galaxy planet age = ...lots of code,
returning a new universe
And the same code for all functions updating any of the properties of
my planet ...
And the same code for all functions updating properties of a country
on this
hi there,
Let's say i have a deep nested data structure.
Universe containing galaxies, containing solar systems, containing
planets, containing countries, containing inhabitants, containing
...whatever.
Using the OO paradigm, once i get a reference to an inhabitant, i can
update it quite
On 6/3/07, Tillmann Rendel [EMAIL PROTECTED] wrote:
In functional programming, problems of the kind and the same code for
all functions doing something related are most often solved by
introducing higher order functions. Let's try to decompose the problem
as follows:
[snip]
Now I've got one
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
Phlex wrote:
This is very informative, and easier to grasp for such a newbie as me.
So the idea is to take the changing function down the chain, i knew
this couldn't be that hard !
Still this requires indeed to think different, I guess i'm up for
quite a few exercises in order to wrap my mind
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
(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,
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
Hello,
Stefan O'Rear wrote:
I've implemented this in Derive[1] in 12 minutes, counting the time
required to re-familiarize with the code. The patch is at [2] and has
also been darcs sent.
Neil Mitchell wrote:
It's been applied, and is now in the main repo.
Wow, that was fast. I didn't
On Sun, 2007-06-03 at 09:02 -0300, Felipe Almeida Lessa wrote:
On 6/3/07, Tillmann Rendel [EMAIL PROTECTED] wrote:
In functional programming, problems of the kind and the same code for
all functions doing something related are most often solved by
introducing higher order functions. Let's
Hi
Speaking of Derive: I tried to install it just a few days ago, and failed.
'Derive' needed 'filepath-any', which needed 'directory-any', which I
couldn't find (in Hackage or on Neil's website).
Either:
1) Use GHC 6.6.1, which comes with filepath
2) Use the hackage version:
Hi
I'm trying to write a function:
reaches :: Type - Q [Type]
The intention is that reaches (Either Bool [Int]) would return [Either
Bool [Int], Bool, [Int], Int] - i.e. all types which are contained by
the initial type at any level.
I took a shot at this:
getTypes :: Type - Q [Type]
The site seems to be asking for the internal floating point
representation. So it doesn't matter if it's IEEE 754, if the ints are
2-complements, or whatever. I used this code as a quick hack for one of
my programs, but I think it would work in this case. It should work for
any Storable type.
On 6/3/07, Rafael Almeida [EMAIL PROTECTED] wrote:
The site seems to be asking for the internal floating point
representation. So it doesn't matter if it's IEEE 754, if the ints are
2-complements, or whatever. I used this code as a quick hack for one of
my programs, but I think it would work in
almeidaraf:
On 6/3/07, Rafael Almeida [EMAIL PROTECTED] wrote:
The site seems to be asking for the internal floating point
representation. So it doesn't matter if it's IEEE 754, if the ints are
2-complements, or whatever. I used this code as a quick hack for one of
my programs, but I think
I just got started learning Haskell a few days ago. I've implemented a
numeric data type that can represent some irrational numbers exactly, and
I'd like to instantiate the RealFrac class so I can do truncate, round,
etc., in the most natural way in the language.
Implementing properFraction
30 matches
Mail list logo