[Hugs-users] Record puns, time for removal?

Bulat Ziganshin bulat.ziganshin at gmail.com
Mon Oct 30 02:40:21 EST 2006


Hello Richard,

Monday, October 30, 2006, 4:20:29 AM, you wrote:

> What is a "record PUN"?  Looking at the example,

in h98, you should write smth like this:

data Point = Point {x :: Int, y :: Int}
f (Point {x=x})   =  x

but record pun allows you to compact this into:

f (Point {x})   =  x


Here, it seems like small improvement. But my program contains a lot
of records that i want to use inside functions. i will be glad to see
even improved version of record pun:

data Command = Command {
    cmd_name                 :: !String             
  , cmd_arcspec              ::  String             
  , cmd_arclist              ::  [FilePath]         
  , cmd_arcname              ::  FilePath           
  , cmd_arc_filter           :: !(FileInfo -> Bool) 
  , cmd_filespecs            :: ![String]           
  , cmd_added_arcnames       :: !(IO [FilePath])    
  , cmd_diskfiles            :: !(IO [FileInfo])    
  , cmd_subcommand           :: !Bool               
....
}

process_cmd (Command{*}) = do
   print cmd_name
   ...

Wildcard puns will greatly simplify my top-level code which
manipulates with dozens of fields from this record


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Hugs-Users mailing list