The Artima Developer Community
Sponsored Link

Python Buzz Forum
From Hash Key to Haskell

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Thomas Guest

Posts: 236
Nickname: tag
Registered: Nov, 2004

Thomas Guest likes dynamic languages.
From Hash Key to Haskell Posted: Jan 20, 2008 10:32 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Thomas Guest.
Original Post: From Hash Key to Haskell
Feed Title: Word Aligned: Category Python
Feed URL: http://feeds.feedburner.com/WordAlignedCategoryPython
Feed Description: Dynamic languages in general. Python in particular. The adventures of a space sensitive programmer.
Latest Python Buzz Posts
Latest Python Buzz Posts by Thomas Guest
Latest Posts From Word Aligned: Category Python

Advertisement

Mac Hash

How annoying, there’s no hash key on the Mac UK keyboard!

SHIFT+3 gets you the UK pound sign, £ (I’d prefer the Euro, €), and once you’ve found that you’re in the right vicinity — as if by magic, ALT+3 produces the #.

Unfortunately this same key combination doesn’t work on the Windows XP virtual machine I run under Parallels. I’ve done enough configuring to get the Mac keyboard working tolerably with this virtualised XP, but whenever I need to enter a # I’m reduced to cutting and pasting.

Trigraph Confusion

C and C++ programmers could avoid the # by using trigraphs, an obscure language feature which allows you to write ??= instead. Yes, there are other trigraphs. Courtesy of Wikipedia, here’s an example program which uses them all.

??=include <stdio.h>

int main(void)
??<
    char n??(5??);
    n??(4??) = '0' - (??-0 ??' 1 ??! 2);
    printf("%c??/n", n??(4??));
    return 0;
??>

Impressively unreadable!

What you see is not what you type

An important difference between a typewriter and a text editor is the software between keypress and screen update — the software I’ve failed to fully configure on my virtual XP machine. So why not exploit this indirection?

Developers of mobile phones have grown ingenious at adapting a numeric keypad to generate text almost as ably as a QWERTY one. (Which do serious texters prefer, I wonder, an iphone or a numeric keypad?) And my instant messenger client is cute enough to display smiley punctuation sequences as emoticon graphics.

Python smiley

On which point, has anyone else noticed the square-jawed smiley you get when you chop the last element from a Python list? This one’s wearing a cap.

q[:-1]

Readable Haskell

Haskell is one of my shiny new things for 2008. I’ve scratched at it before and one of the things which put me off is the number of digraphs in the code. They don’t look right. I’m talking about the arrows in particular:

->  <-  =>

Of course I’m used to the logical digraphs &&, || and the comparison operators, ==, <= etc. These don’t look out of place in the C family of languages, but Haskell’s roots seem closer to mathematics and logic; it craves proper mathematical and logical symbols.

Haskell Logo

The symbol Haskell uses for anonymous functions is a single backslash, \. This should of course be a lambda, λ. It’s ironic that this character is the star of the Haskell homepage but can’t be found in Haskell source code.

It shouldn’t be too hard to view and edit Haskell code using more appropriate characters even if you actually input them as usual. Oh look, Emacs does it already!

Set (setq haskell-font-lock-symbols 'unicode) and your Haskell code will look something like the sample shown in the upper screen below (I’ve split the editor window and shown a plain-text view of the same content in the lower screen).

Emacs Haskell mode screen grab

Much better!

Read: From Hash Key to Haskell

Topic: All we have is less good programmers Previous Topic   Next Topic Topic: Help! The WS-* vs. REST Debate Has Been Hijacked By People Who Want To Have Logical Discussions...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use