[Haskell-cafe] Data creation pattern?

Eugeny N Dzhurinsky bofh at redwerk.com
Thu May 13 14:43:44 EDT 2010


On Thu, May 13, 2010 at 07:14:25PM +0100, Stephen Tetley wrote:
> Hi Eugene
> 
> Is something like this close to what you want:

Not really. First of all, there're many properties, not 3. So it may end up
with plenty of support (boilerplate) code.

Also, names of these parameters are not sortable. Of course I could make these
names as another data type with deriving from Eq/Ord - but that increase
complexity as well.

Original idea was

1) create Array
2) if line "param_N_name=value" appear, then 
2.1) try to take object N from array
2.2) if no object exists - then create one
2.3) set the property "name" to "value"
2.4) put resulting object back into array
3) take next line and go to 2

so if it is possible to have partially initialized objects in Haskell, then
this approach should work. If now - well, then replace creation of object with
adding name/value pair to an array. And then create objects from those arrays.

-- 
Eugene Dzhurinsky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100513/ecf7841c/attachment.bin


More information about the Haskell-Cafe mailing list