From alexteslin at yahoo.co.uk Thu Oct 19 17:13:58 2006 From: alexteslin at yahoo.co.uk (Alex Teslin) Date: Thu Oct 19 16:18:54 2006 Subject: [Hugs-users] converting to capital letters Message-ID: <20061019211358.61454.qmail@web27315.mail.ukl.yahoo.com> Hi, I am a newbie in Haskell and have some problem of defining a function that would convert all small letters to capital and leave the rest intact. I have managed to do with two functions: capitalise :: String -> String capitalise xs = [capitalise2 ch| ch<-xs] capitalise2 :: Char -> Char capitalise2 ch | isLower ch = chr (ord ch - 32) | otherwise = ch But in the book exercise it asks to define as a single function. I tried like this: capitalise :: String -> String capitalise xs = [chr (ord ch - 32) | ch<-xs, isLower ch] But this returns only converted characters, the rest is ignored. Any help would be much appriciated. Send instant messages to your online friends http://uk.messenger.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/hugs-users/attachments/20061019/ded75679/attachment.htm From ndmitchell at gmail.com Thu Oct 19 17:16:26 2006 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Oct 19 16:21:23 2006 Subject: [Hugs-users] converting to capital letters In-Reply-To: <20061019211358.61454.qmail@web27315.mail.ukl.yahoo.com> References: <20061019211358.61454.qmail@web27315.mail.ukl.yahoo.com> Message-ID: <404396ef0610191416q846e88du8c5a7f6c2ea66e69@mail.gmail.com> Hi Alex, I suggest you try haskell-cafe@haskell.org, its a much better place to ask these sorts of Haskell style questions. The answer is to use an "if" expression somewhere, I'll leave you to figure out where :) Thanks Neil On 10/19/06, Alex Teslin wrote: > Hi, > I am a newbie in Haskell and have some problem of defining a function that > would convert all small letters to capital and leave the rest intact. > I have managed to do with two functions: > > capitalise :: String -> String > capitalise xs = [capitalise2 ch| ch<-xs] > > capitalise2 :: Char -> Char > capitalise2 ch > | isLower ch = chr (ord ch - 32) > | otherwise = ch > > But in the book exercise it asks to define as a single function. I tried > like this: > > capitalise :: String -> String > capitalise xs = [chr (ord ch - 32) | ch<-xs, isLower ch] > > But this returns only converted characters, the rest is ignored. > > Any help would be much appriciated. > > > Send instant messages to your online friends http://uk.messenger.yahoo.com > _______________________________________________ > Hugs-Users mailing list > Hugs-Users@haskell.org > http://www.haskell.org/mailman/listinfo/hugs-users > > > From ndmitchell at gmail.com Fri Oct 27 11:57:54 2006 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Oct 27 11:02:25 2006 Subject: [Hugs-users] Record puns, time for removal? Message-ID: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> Hi, I was just looking into Yhc and noticed that it supports record puns, for example the following code: ------ module Main where data Point = Point {x :: Int, y :: Int} main = print $ f $ Point 1 2 f (Point{x}) = x ------ Works fine in Yhc and Hugs, but not in GHC. Is this feature supported/encouraged or is it depreciated and scheduled for removal? I am tempted to remove this feature from Yhc since it seems no one uses it, and GHC doesn't know about it, but was wondering what the Hugs plans were for it first. Thanks Neil From iavor.diatchki at gmail.com Fri Oct 27 15:55:31 2006 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Fri Oct 27 15:00:04 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> Message-ID: <5ab17e790610271255u578370dej6e3457be0230756c@mail.gmail.com> Hello, This feature was removed from Haskell (I was never sure why). However, I think it is a handy feature and should certainly not be removed if it is already implemenetd. -Iavor On 10/27/06, Neil Mitchell wrote: > Hi, > > I was just looking into Yhc and noticed that it supports record puns, > for example the following code: > > ------ > module Main where > data Point = Point {x :: Int, y :: Int} > main = print $ f $ Point 1 2 > f (Point{x}) = x > ------ > > Works fine in Yhc and Hugs, but not in GHC. Is this feature > supported/encouraged or is it depreciated and scheduled for removal? I > am tempted to remove this feature from Yhc since it seems no one uses > it, and GHC doesn't know about it, but was wondering what the Hugs > plans were for it first. > > Thanks > > Neil > _______________________________________________ > Hugs-Users mailing list > Hugs-Users@haskell.org > http://www.haskell.org/mailman/listinfo/hugs-users > From ndmitchell at gmail.com Fri Oct 27 16:57:12 2006 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Oct 27 16:01:43 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <5ab17e790610271255u578370dej6e3457be0230756c@mail.gmail.com> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> <5ab17e790610271255u578370dej6e3457be0230756c@mail.gmail.com> Message-ID: <404396ef0610271357v2efc7afax9582dca022f86bb2@mail.gmail.com> Hi > This feature was removed from Haskell (I was never sure why). > However, I think it is a handy feature and should certainly not be > removed if it is already implemenetd. Does it make sense to have a feature that is available in Hugs and Yhc bug not GHC? I'd suggest that if you want this feature, you try and get it put back in for Haskell Prime. I personally have no particular feeling one way or the other about this feature - I just want to remove configuration flags from Yhc that no-one understands and move towards standard Haskell. Thanks Neil > On 10/27/06, Neil Mitchell wrote: > > Hi, > > > > I was just looking into Yhc and noticed that it supports record puns, > > for example the following code: > > > > ------ > > module Main where > > data Point = Point {x :: Int, y :: Int} > > main = print $ f $ Point 1 2 > > f (Point{x}) = x > > ------ > > > > Works fine in Yhc and Hugs, but not in GHC. Is this feature > > supported/encouraged or is it depreciated and scheduled for removal? I > > am tempted to remove this feature from Yhc since it seems no one uses > > it, and GHC doesn't know about it, but was wondering what the Hugs > > plans were for it first. > > > > Thanks > > > > Neil > > _______________________________________________ > > Hugs-Users mailing list > > Hugs-Users@haskell.org > > http://www.haskell.org/mailman/listinfo/hugs-users > > > From bulat.ziganshin at gmail.com Fri Oct 27 13:17:45 2006 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Oct 27 16:34:47 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> Message-ID: <239257489.20061027211745@gmail.com> Hello Neil, Friday, October 27, 2006, 7:57:54 PM, you wrote: > I was just looking into Yhc and noticed that it supports record puns, > f (Point{x}) = x > Works fine in Yhc and Hugs, but not in GHC. Is this feature > supported/encouraged or is it depreciated and scheduled for removal? I > am tempted to remove this feature from Yhc since it seems no one uses > it, and GHC doesn't know about it, but was wondering what the Hugs > plans were for it first. i've used it a lot in my program until i switched to ghc and was forced to rewrite all this code. if it is possible, i ill vote to add ghc support for this feature. i don't propose it for h' because current records implementation in haskell seems like somewhat temporary solution -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ndmitchell at gmail.com Fri Oct 27 18:09:59 2006 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Oct 27 17:14:29 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <239257489.20061027211745@gmail.com> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> <239257489.20061027211745@gmail.com> Message-ID: <404396ef0610271509q7c942ae3i9cbb27fa13f85eaa@mail.gmail.com> Hi > i don't propose it for h' because > current records implementation in haskell seems like somewhat > temporary solution It sounds like functional dependencies are also going to be temporary feature, until whatever replaces them. If anyone wants to use puns this time next year, I recommend someone proposes them for Haskell Prime - they have 2 implementations, are well established, theoretically sound and seem to have a lot more people who want them than I ever knew! Yet despite this, I never even knew they existed, and there are quite a few places I could have used them, now I know what they are. Thanks Neil From ross at soi.city.ac.uk Fri Oct 27 19:37:41 2006 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Oct 27 18:42:13 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> Message-ID: <20061027233741.GA3163@soi.city.ac.uk> On Fri, Oct 27, 2006 at 04:57:54PM +0100, Neil Mitchell wrote: > I was just looking into Yhc and noticed that it supports record puns, > for example the following code: > > ------ > module Main where > data Point = Point {x :: Int, y :: Int} > main = print $ f $ Point 1 2 > f (Point{x}) = x > ------ > > Works fine in Yhc and Hugs, but not in GHC. Is this feature > supported/encouraged or is it depreciated and scheduled for removal? I > am tempted to remove this feature from Yhc since it seems no one uses > it, and GHC doesn't know about it, but was wondering what the Hugs > plans were for it first. It was removed in Haskell 98 (Hugs only allows it in -98 mode): http://www.cs.chalmers.se/~rjmh/Haskell/Messages/Decision.cgi?id=372 It's probably not coming back, it's incompatible, and it's only a minor shortcut: it might as well go. From gwright at comcast.net Sat Oct 28 12:59:59 2006 From: gwright at comcast.net (Gregory Wright) Date: Sat Oct 28 12:04:28 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> Message-ID: <8F85FE95-5C5A-4777-8F43-3A45F05FDCDF@comcast.net> hi Neil, On Oct 27, 2006, at 11:57 AM, Neil Mitchell wrote: > Hi, > > I was just looking into Yhc and noticed that it supports record puns, > for example the following code: > > ------ > module Main where > data Point = Point {x :: Int, y :: Int} > main = print $ f $ Point 1 2 > f (Point{x}) = x > ------ > > Works fine in Yhc and Hugs, but not in GHC. Is this feature > supported/encouraged or is it depreciated and scheduled for removal? I > am tempted to remove this feature from Yhc since it seems no one uses > it, and GHC doesn't know about it, but was wondering what the Hugs > plans were for it first. > There was some discussion on the haskell' list about bring back record puns, which were once in ghc. Record punning would have been very helpful on one of my recent projects, where I had some large arrays of statically initialized records. The longFieldSelectorNamesToAvoidNamespaceClashes are just noise is such a case. Best Wishes, Greg > Thanks > > Neil > _______________________________________________ > Hugs-Users mailing list > Hugs-Users@haskell.org > http://www.haskell.org/mailman/listinfo/hugs-users From ok at cs.otago.ac.nz Sun Oct 29 20:20:29 2006 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Sun Oct 29 20:20:33 2006 Subject: [Hugs-users] Record puns, time for removal? Message-ID: <200610300120.k9U1KTfN202282@atlas.otago.ac.nz> What is a "record PUN"? Looking at the example, > module Main where > data Point = Point {x :: Int, y :: Int} > main = print $ f $ Point 1 2 > f (Point{x}) = x is the problem that "x" is used simultaneously as a field selector and a variable? Something very similar is accepted by SML/NJ: datatype point = POINT of { x : int, y : int }; fun f (POINT {x, y}) = x; print (Int.toString (f (POINT {x = 1, y = 2})) ^ "\n"); The MLton compiler also likes it. I should also point out that it's not just Yhc and Hugs that like the Haskell version; the copy of hbc I have also likes it. From simonpj at microsoft.com Mon Oct 30 07:11:23 2006 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Mon Oct 30 07:11:26 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <8F85FE95-5C5A-4777-8F43-3A45F05FDCDF@comcast.net> References: <404396ef0610270857v23da104bmad3299563440aab3@mail.gmail.com> <8F85FE95-5C5A-4777-8F43-3A45F05FDCDF@comcast.net> Message-ID: <036EAC76E7F5EC4996A3B3C3657D4116070D5BF4@EUR-MSG-21.europe.corp.microsoft.com> | There was some discussion on the haskell' list about bring back | record puns, which were once in ghc. | | Record punning would have been very helpful on one of my recent | projects, where I had some large arrays of statically initialized | records. | The longFieldSelectorNamesToAvoidNamespaceClashes are just | noise is such a case. I always thought it was a mistake to remove record puns in H98. I would not be against re-introducing them into GHC, since they appear to remain in Hugs and are in Yhc. Simon From bulat.ziganshin at gmail.com Mon Oct 30 02:40:21 2006 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Oct 30 10:52:46 2006 Subject: [Hugs-users] Record puns, time for removal? In-Reply-To: <200610300120.k9U1KTfN202282@atlas.otago.ac.nz> References: <200610300120.k9U1KTfN202282@atlas.otago.ac.nz> Message-ID: <1164816394.20061030104021@gmail.com> 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@gmail.com