Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL

I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔ But I keep getting error messages from the GHC parser. Is there a way to make GHC parse my source files correctly? If it is not possible yet, please consider this as a “feature request”. Best Regards, Cetin Sert INF 521, 4-6-2 69120 Heidelberg Germany http://www.corsis.de

cetin.sert:
I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions NOT, *, *, ->, <-> But I keep getting error messages from the GHC parser. Is there a way to make GHC parse my source files correctly? If it is not possible yet, please consider this as a "feature request".
The "survey of Haskell unicode support" might have some advice, http://blog.kfish.org/2007/10/survey-haskell-unicode-support.html See also -XUnicodeSyntax for enabling unicode keywords for -> <- forall et al. This is turning into an FAQ, so clarifying the unicode support in the GHC user's guide would be a good result. -- Don

Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}" at the beginning of a .hs source file in Visual Haskell nor setting the ghc options from the project properties seems to solve the problem. I keep getting "Error 1 lexical error (UTF-8 decoding error) C:\Users\Sert\Lab\Haskell\HaskellApp1\HaskellApp1\src\Explogic.hs Line 25 Column 2 " in the IDE. Maybe this is Visual Haskell-specific o_O!? -- not (¬) :: P a => a -> Bool (¬) a | g a = False | otherwise = True Best Regards, Cetin Sert -----Original Message----- From: Don Stewart [mailto:dons@galois.com] Sent: Mittwoch, 9. Januar 2008 18:24 To: Cetin Sert Cc: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL cetin.sert:
I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions NOT, *, *, ->, <-> But I keep getting error messages from the GHC parser. Is there a way to make GHC parse my source files correctly? If it is not possible yet, please consider this as a "feature request".
The "survey of Haskell unicode support" might have some advice, http://blog.kfish.org/2007/10/survey-haskell-unicode-support.html See also -XUnicodeSyntax for enabling unicode keywords for -> <- forall et al. This is turning into an FAQ, so clarifying the unicode support in the GHC user's guide would be a good result. -- Don

Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert:
Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}"
First, I think, you have to use -XUnicodeSyntax (as Don said), and not -xunicodesyntax. Second, -XUnicodeSyntax only enables alternative notation for certain built-in syntax (as Don said). Unicode for operators is a different matter. I’d think, it should work out of the box and wonder a bit why it doesn’t.
[…]
Best wishes, Wolfgang

On Wed, Jan 09, 2008 at 10:23:05PM +0100, Wolfgang Jeltsch wrote:
Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert:
Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}"
First, I think, you have to use -XUnicodeSyntax (as Don said), and not -xunicodesyntax. Second, -XUnicodeSyntax only enables alternative notation for certain built-in syntax (as Don said).
Unicode for operators is a different matter. I’d think, it should work out of the box and wonder a bit why it doesn’t.
The give-away is that GHC gave a "UTF-8 decoding error". This says that Cetin is using a different encoding, presumably (due to his mention of Visual Haskell, ergo Windows) UTF-16. Stefan

I'm making sure that my project files are all saved in UTF-8: I'm not newbie enough to miss something like that. I suspect something between Visual Studio and the background GHC instance that feeds it with syntax highlighting and environment information (like a list of functions that are accessible or inferred type infos etc..) might be causing a miscommunication with regards to the file encodings. I also tried writing -XUnicodeSyntax. I'll try to use some other editor and directly call the compiler to see if it works. Thanks for all your support ^_^ Best Regards, Cetin Sert http://www.corsis.de -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Stefan O'Rear Sent: Mittwoch, 9. Januar 2008 23:49 To: Wolfgang Jeltsch Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Problems with Unicode Symbols as Infix Function Names in Propositional Calculus Haskell DSL On Wed, Jan 09, 2008 at 10:23:05PM +0100, Wolfgang Jeltsch wrote:
Am Mittwoch, 9. Januar 2008 18:34 schrieb Cetin Sert:
Neither appending "{-# OPTIONS_GHC -fglasgow-exts -xunicodesyntax #-}"
First, I think, you have to use -XUnicodeSyntax (as Don said), and not -xunicodesyntax. Second, -XUnicodeSyntax only enables alternative notation for certain built-in syntax (as Don said).
Unicode for operators is a different matter. I’d think, it should work out of the box and wonder a bit why it doesn’t.
The give-away is that GHC gave a "UTF-8 decoding error". This says that Cetin is using a different encoding, presumably (due to his mention of Visual Haskell, ergo Windows) UTF-16. Stefan

On Jan 9, 2008 3:17 PM, Cetin Sert
I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔
I guess you can't do anything for ¬, as it is a prefix function. But for the others, what is wrong with e.g. (\/), (/\), (-->) and (<->)? You could write things like 'a /\ b --> c'. -- Felipe.

Am Mittwoch, 9. Januar 2008 18:24 schrieb Felipe Lessa:
[…]
But for the others, what is wrong with e.g. (\/), (/\), (-->) and (<->)?
These are not the true symbols. They look ugly compared to the real ones. Nice typography is a great thing!
You could write things like 'a /\ b --> c'.
With Cetin’s approach you could write things like “a ∧ b → c”. Doesn’t this look a lot better? :-) Best wishes, Wolfgang

Hi, Attached works fine for me (ghc 6.8.2) You'll have trouble with → though, as ghc steals that symbol for type signature declarations. A ghc expert could probably shed more light; Cheers, Tris GHCi also doesn't (at least for me) print symbol names correctly, but that's a different issue.
ghci Bloop.hs GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( Bloop.hs, interpreted ) Ok, modules loaded: Main. *Main> :browse (�) :: Bool -> Bool (� :: Bool -> Bool -> Bool (� :: Bool -> Bool -> Bool (�) :: Bool -> Bool -> Bool *Main> False ˅ True True
On Wed, Jan 09, 2008 at 06:17:13PM +0100, Cetin Sert wrote:
I want to design a DSL in Haskell for propositional calculus. But instead of using natural language names for functions like or, and, implies etc. I want to use Unicode symbols as infix functions ¬, ˅, ˄, →, ↔ But I keep getting error messages from the GHC parser. Is there a way to make GHC parse my source files correctly? If it is not possible yet, please consider this as a “feature request”.
Best Regards,
Cetin Sert
INF 521, 4-6-2
69120 Heidelberg
Germany
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Tristan Allwood PhD Student Department of Computing Imperial College London
participants (6)
-
Cetin Sert
-
Don Stewart
-
Felipe Lessa
-
Stefan O'Rear
-
Tristan Allwood
-
Wolfgang Jeltsch