"shadowing" keywords like "otherwise"

Hello, I am currently using ghc 6.8.2. With the following, swishParse :: String -> String -> SwishStateIO (Maybe RDFGraph) swishParse fnam inp = do { fmt <- gets $ format ; case fmt of N3 -> swishParseN3 fnam inp otherwise -> do { swishError ("Unsupported file format: "++(show fmt)) 4 ; return Nothing } } I am receiving a shadow warning: Swish/HaskellRDF/SwishCommands.hs:304:12: Warning: Defined but not used: `otherwise' It seems to me that in the code base somewhere that there is a "redefine" of the keyword"otherwise". I haven't read the Haskell 98 Report but I thought that it was not possible to redefine keywords. ?? Kind regards, Vasili

Vasili I. Galchin wrote:
It seems to me that in the code base somewhere that there is a "redefine" of the keyword"otherwise". I haven't read the Haskell 98 Report but I thought that it was not possible to redefine keywords. ??
"otherwise" is not a keyword. It is just defined as a normal function like so: otherwise = True Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de

Hello Vasili, Sunday, June 28, 2009, 10:39:37 AM, you wrote:
; case fmt of N3 -> swishParseN3 fnam inp otherwise -> do { swishError ("Unsupported file format: "++(show fmt)) 4 ; return Nothing } }
first, otherwise aka True is used in *condition* part of case statement. here you should use _ second, otherwise isn't a keyword, just a Prelude definition. here, you assign fmt value to this identifier -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hi Vasili, This isn't really a shadowing/redefinition issue. Here's a perfectly legitimate snippet that compiles fine: f 0 = 0 f otherwise = 1+otherwise Redefinition is when you have: g = let otherwise = not in x -- Kim-Ee VasiliIGalchin wrote:
swishParse :: String -> String -> SwishStateIO (Maybe RDFGraph) swishParse fnam inp = do { fmt <- gets $ format ; case fmt of N3 -> swishParseN3 fnam inp otherwise -> do { swishError ("Unsupported file format: "++(show fmt)) 4 ; return Nothing } }
I am receiving a shadow warning:
Swish/HaskellRDF/SwishCommands.hs:304:12: Warning: Defined but not used: `otherwise'
It seems to me that in the code base somewhere that there is a "redefine" of the keyword"otherwise". I haven't read the Haskell 98 Report but I thought that it was not possible to redefine keywords. ??
-- View this message in context: http://www.nabble.com/%22shadowing%22-keywords-like-%22otherwise%22-tp242391... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

I meant, of course, g = let otherwise = not in otherwise Sorry for the noise. -- Kim-Ee Kim-Ee Yeoh wrote:
Hi Vasili,
This isn't really a shadowing/redefinition issue. Here's a perfectly legitimate snippet that compiles fine:
f 0 = 0 f otherwise = 1+otherwise
Redefinition is when you have:
g = let otherwise = not in x
-- Kim-Ee
VasiliIGalchin wrote:
swishParse :: String -> String -> SwishStateIO (Maybe RDFGraph) swishParse fnam inp = do { fmt <- gets $ format ; case fmt of N3 -> swishParseN3 fnam inp otherwise -> do { swishError ("Unsupported file format: "++(show fmt)) 4 ; return Nothing } }
I am receiving a shadow warning:
Swish/HaskellRDF/SwishCommands.hs:304:12: Warning: Defined but not used: `otherwise'
It seems to me that in the code base somewhere that there is a "redefine" of the keyword"otherwise". I haven't read the Haskell 98 Report but I thought that it was not possible to redefine keywords. ??
-- View this message in context: http://www.nabble.com/%22shadowing%22-keywords-like-%22otherwise%22-tp242391... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Sun, Jun 28, 2009 at 12:49:12AM -0700, Kim-Ee Yeoh wrote:
This isn't really a shadowing/redefinition issue. Here's a perfectly legitimate snippet that compiles fine:
f 0 = 0 f otherwise = 1+otherwise
What? It is a redefinition issue *as well*, but this kind of warning isn't active by default Prelude> :s -Wall Prelude> let f 0 = 0; f otherwise = 1 + otherwise <interactive>:1:15: Warning: This binding for `otherwise' shadows the existing binding imported from Prelude In the definition of `f' -- Felipe.

Whoops, you're right. Interestingly, the shadowing warnings vary between the 2 examples I gave, i.e. shadowing within 'function definition' vs 'binding group'. Felipe Lessa wrote:
On Sun, Jun 28, 2009 at 12:49:12AM -0700, Kim-Ee Yeoh wrote:
This isn't really a shadowing/redefinition issue. Here's a perfectly legitimate snippet that compiles fine:
f 0 = 0 f otherwise = 1+otherwise
What? It is a redefinition issue *as well*, but this kind of warning isn't active by default
Prelude> :s -Wall Prelude> let f 0 = 0; f otherwise = 1 + otherwise
<interactive>:1:15: Warning: This binding for `otherwise' shadows the existing binding imported from Prelude In the definition of `f'
-- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://www.nabble.com/%22shadowing%22-keywords-like-%22otherwise%22-tp242391... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Jun 28, 2009, at 02:39 , Vasili I. Galchin wrote:
; case fmt of N3 -> swishParseN3 fnam inp otherwise -> do { swishError ("Unsupported file format: "++(show fmt)) 4 ; return Nothing } }
I am receiving a shadow warning:
Swish/HaskellRDF/SwishCommands.hs:304:12: Warning: Defined but not used: `otherwise'
1. "otherwise" isn't a keyword, it's a function (well, CAF). 2. if you use a variable in a case alternative, that variable is created and bound. I think you wanted to use "_" instead of "otherwise" there. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (6)
-
Brandon S. Allbery KF8NH
-
Bulat Ziganshin
-
Felipe Lessa
-
Janis Voigtlaender
-
Kim-Ee Yeoh
-
Vasili I. Galchin