Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 09:03:48PM +0200, Daniel Fischer wrote: > > so if it is possible to have partially initialized objects in Haskell, > If the fields aren't strict, there's no problem having > ... Wow! Thank you, that's it :) -- Eugene Dzhurinsky pgpPXFjii1ixC.pgp Description: PGP signatu

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Daniel Fischer
On Thursday 13 May 2010 20:43:44, Eugeny N Dzhurinsky wrote: > 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 suppor

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
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.

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 07:15:22PM +0100, Stephen Tetley wrote: > On 13 May 2010 19:14, Stephen Tetley wrote: > > Hi Eugene > > Hi Eugeny > Whoops - apologies for the the name change... In fact it doesn't make any difference, so both these names are equal :) -- Eugene Dzhurinsky pgpHrKKK4J1f

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Stephen Tetley
On 13 May 2010 19:24, Steffen Schuldenzucker wrote: > Or just: > > makeOrdered a b c = let (s:t:u:_) = sort [a, b, c] in Object s t u > Hi Steffen True - but it does include a partial pattern (that will always match in this case, of course). ___ Haske

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Steffen Schuldenzucker
Hi. Stephen Tetley wrote: Hi Eugene Is something like this close to what you want: For example this builds an object with ordered strings... makeOrdered :: String -> String -> String -> Object makeOrdered a b c = let (s,t,u) = sort3 (a,b,c) in Object s t u Or just: makeOrdered a b c = le

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Stephen Tetley
On 13 May 2010 19:14, Stephen Tetley wrote: > Hi Eugene Hi Eugeny Whoops - apologies for the the name change... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Stephen Tetley
Hi Eugene Is something like this close to what you want: For example this builds an object with ordered strings... makeOrdered :: String -> String -> String -> Object makeOrdered a b c = let (s,t,u) = sort3 (a,b,c) in Object s t u Alternatively you could build the with the Strings as they appe

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 04:43:26PM +0100, Stephen Tetley wrote: > Hi Eugene > > You don't need to supply all the arguments to a constructor at once: > > makeWithOne :: String -> (String -> String -> Object) > makeWithOne s1 = \s2 s3 -> Object s1 s2 s3 > > -- or even: > -- makeWithOne s1 = Object

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Stephen Tetley
Hi Eugene You don't need to supply all the arguments to a constructor at once: makeWithOne :: String -> (String -> String -> Object) makeWithOne s1 = \s2 s3 -> Object s1 s2 s3 -- or even: -- makeWithOne s1 = Object s1 This builds a higher-order function that can be applied later to two Strings

[Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugene Dzhurinsky
Hello, all! I need to create objects like this data Object = MyObject { param1, param2, param3 :: String } from the input file param_1_param1=value11 param_2_param1=value21 param_2_param2=value22 param_1_param3=value13 param_2_param3=value23 param_1_param2=value12 so general pattern of recogni