Unicode Haskell source -- Yippie!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Unicode Haskell source -- Yippie!

Rustom Mody
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

-- Numbers
x ≠ y   = x /= y
x ≤ y   = x <= y
x ≥ y   = x >= y
x ÷ y   = divMod x y
x ⇑ y   = x ^ y
        
x × y   = x * y -- readability hmmm !!!
π = pi  
        
-- ⌊ x = floor x
-- ⌈ x = ceiling x

-- Lists        
xs ⤚ ys = xs ++ ys

-- Bools
x ∧ y   = x && y
x ∨ y   = y || y
-- ¬x = not x


-- Sets

x ∈ s   = x `Set.member` s -- or keep ∈ for list elem?
s ∪ t   = s `Set.union` t
s ∩ t   = s `Set.intersection` t
s ⊆ t   = s `Set.isSubsetOf` t
s ⊂ 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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Brandon Allbery
On Thu, Apr 24, 2014 at 1:15 PM, Rustom Mody <[hidden email]> 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
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

MigMit
In reply to this post by Rustom Mody
It's disgusting.

Отправлено с iPhone

> 24 апр. 2014 г., в 21:15, Rustom Mody <[hidden email]> написал(а):
>
> 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
>
> -- Numbers
> x ≠ y   = x /= y
> x ≤ y   = x <= y
> x ≥ y   = x >= y
> x ÷ y   = divMod x y
> x ⇑ y   = x ^ y
>          
> x × y   = x * y -- readability hmmm !!!
> π = pi  
>          
> -- ⌊ x = floor x
> -- ⌈ x = ceiling x
>
> -- Lists        
> xs ⤚ ys = xs ++ ys
>
> -- Bools
> x ∧ y   = x && y
> x ∨ y   = y || y
> -- ¬x = not x
>
>
> -- Sets
>
> x ∈ s   = x `Set.member` s -- or keep ∈ for list elem?
> s ∪ t   = s `Set.union` t
> s ∩ t   = s `Set.intersection` t
> s ⊆ t   = s `Set.isSubsetOf` t
> s ⊂ 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Kyle Murphy-2
In reply to this post by Rustom Mody
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
--
Curiosity was framed, Ignorance killed the cat.


On Thu, Apr 24, 2014 at 1:15 PM, Rustom Mody <[hidden email]> wrote:
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

-- Numbers
x ≠ y   = x /= y
x ≤ y   = x <= y
x ≥ y   = x >= y
x ÷ y   = divMod x y
x ⇑ y   = x ^ y
        
x × y   = x * y -- readability hmmm !!!
π = pi  
        
-- ⌊ x = floor x
-- ⌈ x = ceiling x

-- Lists        
xs ⤚ ys = xs ++ ys

-- Bools
x ∧ y   = x && y
x ∨ y   = y || y
-- ¬x = not x


-- Sets

x ∈ s   = x `Set.member` s -- or keep ∈ for list elem?
s ∪ t   = s `Set.union` t
s ∩ t   = s `Set.intersection` t
s ⊆ t   = s `Set.isSubsetOf` t
s ⊂ 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



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Rustom Mody



On Thu, Apr 24, 2014 at 10:57 PM, Kyle Murphy <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Sylvain HENRY
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.pdf


2014-04-24 19:36 GMT+02:00 Rustom Mody <[hidden email]>:



On Thu, Apr 24, 2014 at 10:57 PM, Kyle Murphy <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Nickolay Kudasov
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 <[hidden email]>:



On Thu, Apr 24, 2014 at 10:57 PM, Kyle Murphy <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Roel van Dijk-3
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
(∈) = elem

You 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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Tikhon Jelvis
I'm actually a fan of using Unicode in my code. As people like to say, code is read more often than it's written, so I'm willing to make typing a bit harder in return for making the code prettier.

Happily, typing Unicode characters is quite easy with a good editor (Emacs). I use the TeX input mode which just lets me use TeX names for symbols, but somebody has actually written a Haskell-specific mode which might be even better[1]. I might try it some day.

One peculiar habit I have is using x₁ x₂ x₃ instead of x1, x2, x3 or x_1, x_2, x_3. I definitely find the Unicode version easier to read and work with, although it probably helps that Emacs highlights the number in a different color.

Unfortunately, this is a minority opinion at the moment. Even in *this* day and age, people still find Unicode too difficult to type!

For my internal code, this is not a problem, but it's kept me from putting any Unicode in public APIs. Shame.

I also don't use UnicodeSyntax because Emacs can do most of the transformations transparently for me without changing the underlying file. You can turn this on by setting `haskell-font-lock-symbols' to t. I find it makes for much nicer code that's easier to read and, even more importantly, easier to skim.

[1]: https://github.com/roelvandijk/emacs-haskell-unicode-input-method


On Thu, Apr 24, 2014 at 12:51 PM, Roel van Dijk <[hidden email]> wrote:
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
(∈) = elem

You 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



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Niklas Hambüchen
A smart, recently proposed alternative is using a font that does this
automatically for you: https://github.com/i-tu/Hasklig

In my opinion, this gives you all benefits of unicode syntax without
imposing the drawbacks on others, and you don't even have to set up a
custom input method to conveniently type them in.

Quoting:

Some Haskell programmers have resorted to unicode symbols in code as a
solution (⇒, ← etc.). This opens a whole new can of worms. In addition
to encoding/compatibility problems and all the reasons it never worked
out for APL, these symbols are one-character-wide and therefore
eye-strainingly small.

Hasklig solves this problem the way typographers have always solved
ill-fitting characters which co-occur often: ligatures. The underlying
code stays the same — only the representation changes.

On Thu 24 Apr 2014 21:02:30 BST, Tikhon Jelvis wrote:

> I'm actually a fan of using Unicode in my code. As people like to say,
> code is read more often than it's written, so I'm willing to make
> typing a bit harder in return for making the code prettier.
>
> Happily, typing Unicode characters is quite easy with a good editor
> (Emacs). I use the TeX input mode which just lets me use TeX names for
> symbols, but somebody has actually written a Haskell-specific mode
> which might be even better[1]. I might try it some day.
>
> One peculiar habit I have is using x₁ x₂ x₃ instead of x1, x2, x3 or
> x_1, x_2, x_3. I definitely find the Unicode version easier to read
> and work with, although it probably helps that Emacs highlights the
> number in a different color.
>
> Unfortunately, this is a minority opinion at the moment. Even in
> *this* day and age, people still find Unicode too difficult to type!
>
> For my internal code, this is not a problem, but it's kept me from
> putting any Unicode in public APIs. Shame.
>
> I also don't use UnicodeSyntax because Emacs can do most of the
> transformations transparently for me without changing the underlying
> file. You can turn this on by setting `haskell-font-lock-symbols' to
> t. I find it makes for much nicer code that's easier to read and, even
> more importantly, easier to skim.
>
> [1]: https://github.com/roelvandijk/emacs-haskell-unicode-input-method
>
>
> On Thu, Apr 24, 2014 at 12:51 PM, Roel van Dijk
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     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
>     (∈) = elem
>
>     You 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.
>
>     1
>     - http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#unicode-syntax
>     2 - http://www.haskell.org/haskellwiki/Unicode-symbols
>     3 - http://hackage.haskell.org/package/base-unicode-symbols
>     4 - http://hackage.haskell.org/package/containers-unicode-symbols
>
>     _______________________________________________
>     Haskell-Cafe mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Rustom Mody
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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Niklas Haas
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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Travis Cardwell
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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Christopher Allen
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.


On Fri, Apr 25, 2014 at 1:54 AM, Travis Cardwell <[hidden email]> wrote:
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


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Travis Cardwell
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.html

When 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-icu

The 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/convexp

Cheers,

Travis
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Christopher Allen


On Fri, Apr 25, 2014 at 3:24 AM, Travis Cardwell <[hidden email]> wrote:
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.html

When 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-icu

The 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/convexp

Cheers,

Travis
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Nick Rudnick-2
In reply to this post by Rustom Mody
Thanks for the hint =)

I ever wondered about some special characters on the standard keyboard, 

°  -- i.e. [][^]
§
¢
€ 
¶ --e.g. [Alt Gr][R]
· -- e.g. [Alt Gr][,]
… -- e.g. [Alt Gr][,]
–  -- e.g. [Alt Gr][-], though optically ambiguous with -, a candidate for *unary 
       minus*, which I think ever has been considered to be realized a little 
       unsatisfactorily
¬  e.g. [Alt Gr][6], also a great candidate for unary use

now I see they are usable, too, which to me is great news. 

Since some time, I began using chars like þ, ø, æ, ŋ, ð, µ, ħ, etc., which, easily accessible on a Linux keyboard, have more than cosmetic utility to me; with find / replace it prevents you from the usual trouble when working – but that with the special chars above is a pleasing discovery. :-)

I ever wondered for the reason that in Haskell function composition is not declared by (°) instead of (.), which (a) interferes with other uses of the period and (b) looks less similar to the actual symbol.

It also reminds me of a very beautiful feature (Emacs) haskell-mode had some years ago; it was able to display special characters in wider characters (maybe using a special Emacs font??) – does anybody know what I am speaking about, too?

Unfortunately, this feature wasn't continued while frankly, "←" as in recent use to me slightly hurts the eye a little everywhere it's seen in code (sorry, "←"... ;-), while back then, in Emacs there where BEAUTIFUL arrows in double width and gorgeous lambdas.

Cheers, Nick








2014-04-24 19:15 GMT+02:00 Rustom Mody <[hidden email]>:
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

-- Numbers
x ≠ y   = x /= y
x ≤ y   = x <= y
x ≥ y   = x >= y
x ÷ y   = divMod x y
x ⇑ y   = x ^ y
        
x × y   = x * y -- readability hmmm !!!
π = pi  
        
-- ⌊ x = floor x
-- ⌈ x = ceiling x

-- Lists        
xs ⤚ ys = xs ++ ys

-- Bools
x ∧ y   = x && y
x ∨ y   = y || y
-- ¬x = not x


-- Sets

x ∈ s   = x `Set.member` s -- or keep ∈ for list elem?
s ∪ t   = s `Set.union` t
s ∩ t   = s `Set.intersection` t
s ⊆ t   = s `Set.isSubsetOf` t
s ⊂ 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



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Travis Cardwell
In reply to this post by Christopher Allen
On 2014年04月25日 17:37, Christopher Allen wrote:
> http://lucumr.pocoo.org/2014/1/5/unicode-in-2-and-3/

Much of this article relates to what I wrote in my first reply:

On 2014年04月25日 15:54, Travis Cardwell wrote:
> Python does indeed have great Unicode support, but using Unicode for
> everything is not efficient in cases where it is not needed.

Armin says that Python 3 is not appropriate for real-world applications
due to this issue.  He wants functionality in the standard library that
processes bytes directly (as in Python 2).  The problem is that processing
bytes directly is not safe.  The `urlparse` example is a good one: naively
parsing URLs as bytes can lead to major security vulnerabilities.  While
Armin would not parse things naively, people with less experience with
encodings are less likely to make mistakes in Python 3, at the expense of
performance.

I think that Haskell's support for byte-strings and Unicode strings (as
well as many other encodings via ICU transcoding) is quite nice because it
supports doing whatever needs to be done while giving the programmer the
control necessary to implement real-world applications.  Though one can
still manage to shoot themselves in the foot, Haskell's types make the
confusing subject of encoding more approachable and significantly reduces
chance of error, IMHO.

The article also talks about how Python's codec system is used for
non-character encodings (such as zlib!) in addition to character
encodings.  I do not think that it is particularly good design.  Attempts
to clean up the design have resulted in compatibility issues with old
code: type errors!  As a Haskell programmer, I am clearly biased, but I
think that the design of such modules could be significantly improved by
using static types and type classes! ;)

Cheers,

Travis
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Chris Warburton
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.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,
Chris
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Unicode Haskell source -- Yippie!

Rustom Mody



On Fri, Apr 25, 2014 at 6:32 PM, Chris Warburton <[hidden email]> 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,
Chris

Thanks 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 with
per-char cost decreasing and fixed cost increasing as we go down

1. 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 emacs
3. Window-system (X/MS etc) input methods
4. OS-based input methods
5. Special purpose hardware-keyboards

I believe 3 makes for a particularly good fixed/variable cost balance point

eg in X-windows if you run this command
$ setxkbmap -layout "us,gr" -option "grp:switch"
then typing
abcdefg
with 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 indicator

All 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.

regards
Rusi




_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
123