# Unicode Haskell source -- Yippie!

42 messages
123
Open this post in threaded view
|

## Unicode Haskell source -- Yippie!

 I'm mighty pleased to note that the following is valid Haskell code!Do others find this useful/appealing?Any possibilities on making the commented out parts work? [Pragmatics about typing this at the same speed and facility as we do with Ascii is a separate and (IMHO) solvable problem though its not the case at the moment]-------------------- import qualified Data.Set as Set-- Experimenting with Unicode in Haskell source-- Numbersx ≠ y   = x /= yx ≤ y   = x <= yx ≥ y   = x >= yx ÷ y   = divMod x yx ⇑ y   = x ^ y         x × y   = x * y -- readability hmmm !!!π = pi            -- ⌊ x = floor x-- ⌈ x = ceiling x-- Lists         xs ⤚ ys = xs ++ ys-- Boolsx ∧ y   = x && y x ∨ y   = y || y -- ¬x = not x-- Setsx ∈ s   = x `Set.member` s -- or keep ∈ for list elem?s ∪ t   = s `Set.union` ts ∩ t   = s `Set.intersection` ts ⊆ t   = s `Set.isSubsetOf` ts ⊂ t   = s `Set.isProperSubsetOf` t s ⊈ t   = not (s `Set.isSubsetOf` t)-- ∅ = Set.null _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 On Thu, Apr 24, 2014 at 1:15 PM, Rustom Mody wrote: Any possibilities on making the commented out parts work?Unary operators are not really doable. Take a look at the ugliness around unary minus for why. (Note in particular how it breaks section syntax.) Nullary operators are even less doable; Set.null must be done with an identifier character, not a symbol character. (There are a number of such that would fit, since it is actually used in some languages.) -- brandon s allbery kf8nh                               sine nomine associates unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 On Thu, Apr 24, 2014 at 10:57 PM, Kyle Murphy wrote: It's an interesting feature, and nice if you want that sort of thing, but not something I'd personally want to see as the default. Deviating from the standard ASCII set of characters is just too much of a hurdle to usability of the language. If you really like that sort of thing though you might want to look into APL which is either famous or infamous depending on your outlook for needing its own custom keyboard in order to write it. -R. Kyle Murphy I dont think anyone can reasonably talk of making it a default!Just seeing how much and to where the envelope can be pushed. eg I would like to see \ spelled as λAs for APL, it failed for various reasons eg- mixing up assembly language (straight line code with gotos) with functional idioms - the character set was a major hurdle in the 60s. Thats not an issue today when most OSes/editors are unicode compliant _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 As a first step, it could be useful to provide this kind of syntax for haddock generated HTML sources (read-only). Fortress language provides something similar (see Section 2.3 in the spec [1]). -Sylvain[1] http://www.ccs.neu.edu/home/samth/fortress-spec.pdf2014-04-24 19:36 GMT+02:00 Rustom Mody : On Thu, Apr 24, 2014 at 10:57 PM, Kyle Murphy wrote: It's an interesting feature, and nice if you want that sort of thing, but not something I'd personally want to see as the default. Deviating from the standard ASCII set of characters is just too much of a hurdle to usability of the language. If you really like that sort of thing though you might want to look into APL which is either famous or infamous depending on your outlook for needing its own custom keyboard in order to write it. -R. Kyle Murphy I dont think anyone can reasonably talk of making it a default!Just seeing how much and to where the envelope can be pushed. eg I would like to see \ spelled as λAs for APL, it failed for various reasons eg- mixing up assembly language (straight line code with gotos) with functional idioms - the character set was a major hurdle in the 60s. Thats not an issue today when most OSes/editors are unicode compliant _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 In reply to this post by Rustom Mody eg I would like to see \ spelled as λ ​I have symbol substitution enabled in Vim. E.g. when I write \ (and it is syntactically lambda) I get λ. The same way composition (.) is replaced with ∘. The same trick can be enabled for other operators as well. So I have normal text and nice presentation in my text editor: it does not bother anyone but me. Nick 2014-04-24 21:36 GMT+04:00 Rustom Mody : On Thu, Apr 24, 2014 at 10:57 PM, Kyle Murphy wrote: It's an interesting feature, and nice if you want that sort of thing, but not something I'd personally want to see as the default. Deviating from the standard ASCII set of characters is just too much of a hurdle to usability of the language. If you really like that sort of thing though you might want to look into APL which is either famous or infamous depending on your outlook for needing its own custom keyboard in order to write it. -R. Kyle Murphy I dont think anyone can reasonably talk of making it a default!Just seeing how much and to where the envelope can be pushed. eg I would like to see \ spelled as λAs for APL, it failed for various reasons eg- mixing up assembly language (straight line code with gotos) with functional idioms - the character set was a major hurdle in the 60s. Thats not an issue today when most OSes/editors are unicode compliant _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 In reply to this post by Rustom Mody I think it is a nice feature if used sparingly.Note that while Unicode symbols are a normal part of the Haskell language you can also turn on some Unicode syntax using the UnicodeSyntax [1] language extension. This means the following will be accepted by GHC: (∈) ∷ ∀ α. Eq α ⇒ α → [α] → Bool(∈) = elemYou might want to take a look at some packages I created that define some Unicode symbols for common operators and values [2, 3, 4]. Opinions on whether this is a good idea vary. My anecdotal observation is that it seems to be used more by people who speak a native language that is already poorly served by ASCII. Perhaps because they are already used to not being able to simply type every character they need.  _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 In reply to this post by MigMit Many and varied answers -- this is sure a vibrant place -- Thanks for all suggestions and pointers -- including negative -- I really wish to know the lay-of-the-land!It will sure take me a while to follow up check and get back -- hope thats ok :-) As of this point haskell seems to be ahead of the competition in embracing unicode.  eg python moved to python 3 with a number of backward incompatible changes, the most notable of which is the moving to unicode as the default. However for unicode in python source it still seems people are finding it hard to accept. _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 On Fri, 25 Apr 2014 12:01:41 +0530, Rustom Mody <[hidden email]> wrote: > As of this point haskell seems to be ahead of the competition in embracing > unicode.  eg python moved to python 3 with a number of backward > incompatible changes, the most notable of which is the moving to unicode as > the default. However for unicode in python source it still seems people are > finding it hard to accept. FWIW, python's support for Unicode in its standard library is significantly better than Haskell's. Haskell fails on basic functions such as ‘toUpper’, ‘length’ or ‘==’. _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 On 2014年04月25日 15:34, Niklas Haas wrote: > FWIW, python's support for Unicode in its standard library is > significantly better than Haskell's. Haskell fails on basic functions > such as ‘toUpper’, ‘length’ or ‘==’. I have to humbly disagree.  Python does indeed have great Unicode support, but using Unicode for everything is not efficient in cases where it is not needed.  With Haskell, one can use bytestring [1] and text [2] as necessary to have more control over how content is processed.  Both packages are in Haskell Platform, the equivalent of Python's standard library. Cheers, Travis ---- [1] http://hackage.haskell.org/package/bytestring[2] http://hackage.haskell.org/package/text_______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 On 2014年04月25日 16:25, Christopher Allen wrote: > I'm going to disagree for a different reason. The transition to Python 3 > improved unicode support in some respects, but utterly gutted the > previously excellent codec support. Now you can't really handle arbitrary > source/destination encodings of text without treating everything as if they > were bytes. Really bad. Perhaps I am misunderstanding, but, from my experience, Python 3 still has excellent codec support: https://docs.python.org/3.4/library/codecs.htmlWhen reading from a file, the source encoding can be passed to the `open` function so that it handles transcoding for you.  When writing to a file, the destination encoding can similarly be specified to `open`.  When dealing with other sources/destinations, data must be read/written as bytes, but content can be encoded/decoded as necessary using the functions in the codecs module. Haskell has excellent codec support thanks to ICU: http://hackage.haskell.org/package/text-icuThe contents of the `Data.Text.ICU.Convert` module can be used to convert between codecs.  For reference, here is a list of supported codecs: http://demo.icu-project.org/icu-bin/convexpCheers, Travis _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 In reply to this post by Rustom Mody Rustom Mody <[hidden email]> writes: > As for APL, it failed for various reasons eg > - mixing up assembly language (straight line code with gotos) with > functional idioms > - the character set was a major hurdle in the 60s. Thats not an issue today > when most OSes/editors are unicode compliant I know it's bikeshedding, but I think Agda and Idris are more relevant to Haskell than APL, since their semantics are closer (and they're both implemented in Haskell). Agda makes extensive (ab)use of Unicode identifiers, eg. https://github.com/agda/agda-stdlib/blob/master/src/Algebra.agdaIdris specifically avoids Unicode identifiers, for reasons outlined at https://github.com/idris-lang/Idris-dev/wiki/Unofficial-FAQPersonally I prefer working in Idris to Agda, since the Unicode puts me off. I usually resort to copy/pasting symbols, which is tedious compared to typing names. Cheers, Chris _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
Open this post in threaded view
|

## Re: Unicode Haskell source -- Yippie!

 On Fri, Apr 25, 2014 at 6:32 PM, Chris Warburton wrote: Rustom Mody <[hidden email]> writes: > As for APL, it failed for various reasons eg > - mixing up assembly language (straight line code with gotos) with > functional idioms > - the character set was a major hurdle in the 60s. Thats not an issue today > when most OSes/editors are unicode compliant I know it's bikeshedding, but I think Agda and Idris are more relevant to Haskell than APL, since their semantics are closer (and they're both implemented in Haskell). Agda makes extensive (ab)use of Unicode identifiers, eg. https://github.com/agda/agda-stdlib/blob/master/src/Algebra.agda Idris specifically avoids Unicode identifiers, for reasons outlined at https://github.com/idris-lang/Idris-dev/wiki/Unofficial-FAQ Personally I prefer working in Idris to Agda, since the Unicode puts me off. I usually resort to copy/pasting symbols, which is tedious compared to typing names. Cheers, ChrisThanks Chris for that evaluation. Not bike-shedding as far as I can see.Yes input-ing things by some GUI-picker or copy-pasting etc would quickly become a major pain. I believe that there are roughly these 5 levels to this withper-char cost decreasing and fixed cost increasing as we go down1. GUI-picker (IBUS etc) copy-pasting from the web etc -- ok for arm-chair discussions; ridiculous for serious development 2. Editor based input methods eg tex input-method in emacs3. Window-system (X/MS etc) input methods4. OS-based input methods 5. Special purpose hardware-keyboards I believe 3 makes for a particularly good fixed/variable cost balance pointeg in X-windows if you run this command\$ setxkbmap -layout "us,gr" -option "grp:switch" then typingabcdefgwith right-alt depressed, gives:αβψδεφγFor those who prefer a more moded approach (vi-users?) here is \$ setxkbmap -option "grp:switch,grp:alt_shift_toggle,grp_led:scroll" -layout "us,gr"This makes the Shift-Alt chord switch in and out (ie toggle) greek keyboard with the scroll-lock light as indicatorAll this is clearly just an analogy; what we need is not a greek keyboard but a keyboard mapping analogous to gr(eek). Try s/gr/apl in the commands above for apl which, while distant from haskell gives a taste for what a *programmer* can use/make. regardsRusi _______________________________________________ Haskell-Cafe mailing list [hidden email] http://www.haskell.org/mailman/listinfo/haskell-cafe
123