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 s1 > > This builds a higher-order function that can be applied later to two > Strings to finally make the Object.
Hello, Stephen! Well, that's true, but I don't really know the order of incoming data. So for constructor MyObject { prop1, prop2, prop3 :: String } there can be the cases of order prop1 prop2 prop3 prop3 prop2 prop1 prop1 prop3 prop2 ... so I may need to initialize prop1, then prop3, and finally prop2 to make instance of MyObject. And similarly for another cases. I don't see any easy solution for now except sort name-value pairs in some pre-defined order, and then use something like > props :: [(String,String)] > result = MyObject (props' !! 0) (props' !! 1) (props' !! 2) > where > props' = map snd props which looks ugly and involves some additional calculations for sorting. -- Eugene Dzhurinsky
pgp4LFh60lrNL.pgp
Description: PGP signature
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe