Skip navigation

Haskell CEDICT

I finally wrote a useful Haskell program: an interface to CEDICT. You can look up characters in your Haskell programs, and you can also use a nice command line tool, zi4pu3 (字谱 → “character chart”):

  echo "你好。" | zi4pu3 
  you                                                 你                   ni3
  be fond of                                          好                  hao4
                                                      。

Those who know ‘好’ know that it’s meanings are under-represented here. The data is actuall in CEDICT, but spread over multiple entries — I need to fold them together, and haven’t done so yet.

Really Weird Conversation With David Pollak

========  From: Pierre R

Two interesting reddit post today :

http://www.perl.com/pub/a/2007/12/06/soto-11.html?page=1

http://www.dreamsongs.com/ObjectsHaveFailedNarrative.html

Some people believe Larry Wall is kind of crazy. I have actually a lot
of respect for him. Same for R P Gabriel I guess in a different
genre.

I really like this two guys ... It probably means I am a bit crazy
myself which is a good sign.

It reminds me of Samuel Beckett in "Waiting for Godot" (in French)
"On nait tous fous. Quelques uns le demeurent"

If someone have an English translation ... By the way Beckett mastery
in French is totally amazing.

========
========
=
=
========  From: Jason Dusek

These are neat articles, thanks for forwarding them along. I'm
not really pulling for Perl 6 -- I'd really like to see
something else come along in the scripting space -- but Larry
Wall's perspective is valuable to me even though his language
has ceased to be.

He says "both Perl and Ruby take their functional programming
support rather more seriously than Python does", but Python is
the only one of the three to offer first class functions. I
shudder at the thought of serious functional programming without
functions as values!

========
========
=
=
========  From: David Pollak

Jason Dusek wrote:
> These are neat articles, thanks for forwarding them along. I'm
> not really pulling for Perl 6 -- I'd really like to see
> something else come along in the scripting space -- but Larry
> Wall's perspective is valuable to me even though his language
> has ceased to be.
>
> He says "both Perl and Ruby take their functional programming
> support rather more seriously than Python does", but Python is
> the only one of the three to offer first class functions. I
> shudder at the thought of serious functional programming without
> functions as values!

Ruby has functions as values.  The wacky yield syntax is only sugar on top
of functions as values.

========
========
=
=
========  From: Jason Dusek

David Pollak wrote:
> Ruby has functions as values.  The wacky yield syntax is only
> sugar on top of functions as values.

Ruby has values as functions, but not functions as values. Try
this:

 def plus_one(val)
   val + 1
 end

 plusser = plus_one  # error at this line

Notice how we can not assign a function to a value. To get
close, we have to do the C++/Java trick of making an object with
an agreed upon 'execute' method -- and that is
values-as-functions, not functions-as-values. To put it another
way, functions in Ruby are not first class values.

As an aside, shouldn't "sugar" make the syntax sweeter, instead
of less verbose? I wrote Ruby for two years before learning
Python, by the way; and the switch was totally motivated by the
presence of first class functions in the latter language.

========
========
=
=
========  From: Jason Dusek

Jason Dusek wrote:
> As an aside, shouldn't "sugar" make the syntax sweeter,
> instead of less verbose? I wrote Ruby for two years before
> learning Python, by the way; and the switch was totally
> motivated by the presence of first class functions in the
> latter language.

Please amend the part after second comma, above, to "instead of
more verbose?".

========
========
=
=
========  From: David Pollak

pony:~ dpp$ irb
irb(main):001:0> def plus_one(val); val + 1; end
=> nil
irb(main):002:0> plus_one(33)
=> 34
irb(main):003:0> l =method('plus_one').to_proc

irb(main):007:0> l.call (44)
=> 45

So... even though the syntax is less than optimal, the ability to
store Procs (functions) in arrays, hashes, etc. exists.

========
========
=
=
========  From: Jason Dusek

The difference is *semantic* as well as syntactic -- a function
definition is an *expression* in Python or Haskell or
JavaScript, whereas it is a *statement* in Ruby and C and Perl.

Procs are not functions, they are objects. If you want to see,
just try calling the Proc directly, without calling any of it's
methods.

If you have to wrap a function in something in order to store
it, you by definition do not have first class functions.

========
========
=
=
========  From: David Pollak

Jason Dusek wrote:
> The difference is *semantic* as well as syntactic -- a function
> definition is an *expression* in Python or Haskell or
> JavaScript, whereas it is a *statement* in Ruby and C and Perl.
>
> Procs are not functions, they are objects. If you want to see,
> just try calling the Proc directly, without calling any of it's
> methods.
>
> If you have to wrap a function in something in order to store
> it, you by definition do not have first class functions.

So, Scala is does not have first class functions?  That'd be news to
people writing Scala code.

========
========
=
=
========  From: Jason Dusek
On Dec 6, 2007 6:19 PM, David Pollak wrote:
> On Dec 6, 2007, at 6:16 PM, Jason Dusek wrote:
> > If you have to wrap a function in something in order to store
> > it, you by definition do not have first class functions.
>
> So, Scala is does not have first class functions?  That'd be news to
> people writing Scala code.

You are going to have to show me some code before I can
say anything at all -- otherwise, what we've got here is
argument from authority ("those Scala people must know what they
are doing").

========
========
=
=
========  From: David Pollak

On Dec 6, 2007 6:34 PM, Jason Dusek  wrote:
> On Dec 6, 2007 6:19 PM, David Pollak  wrote:
> > On Dec 6, 2007, at 6:16 PM, Jason Dusek wrote:
> > > If you have to wrap a function in something in order to store
> > > it, you by definition do not have first class functions.
> >
> > So, Scala is does not have first class functions?  That'd be news to
> > people writing Scala code.
>
> You are going to have to show me some code before I can
> say anything at all -- otherwise, what we've got here is
> argument from authority ("those Scala people must know what they
> are doing").

lambda calculus in Ruby:
http://meta-meta.blogspot.com/2007/06/church-code.html

What is Scala?

Scala is a general purpose programming language designed to
express common programming patterns in a concise, elegant, and
type-safe way. It smoothly integrates features of
object-oriented and functional languages. It is also fully
interoperable with Java.

http://www.scala-lang.org/

Everything (even functions) are stored as Objects in both Scala
and Ruby.

Both have methods to invoke the functions (Scala calls this
method "apply" and Ruby calls it "call").  The Scala compiler
will convert f() to f.apply() if f is a subclass of Function,
but that's syntactic sugar on top of the Object wrapper.

They are functions because they are units of code that are
optionally bound to variables in a different scope (unlike
function pointers in C.)

They can be passed as parameters and they can be stored in data
structures (Lists, Hashes, etc.)

In terms of questioning the authority of a a large number of
people with PhDs in computer science as to whether Scala is a
functional programming language, where does your authority come
from?  Do you have a PhD?  What is your list of articles
published in peer reviewed journals?

Thanks

========
========
=
=
========  From: Jason Dusek 

David Pollak wrote:
> Both have methods to invoke the functions (Scala calls this
> method "apply" and Ruby calls it "call").  The Scala compiler
> will convert f() to f.apply() if f is a subclass of Function,
> but that's syntactic sugar on top of the Object wrapper.

That's part of the answer -- but how do you define functions in
Scala? Is Scala function definition in the world of statements
or the world of expressions?

> where does your authority come from?  Do you have a PhD?  What
> is your list of articles published in peer reviewed journals?

I don't have a college education, David -- but I have millions
of dollars. Ergo, I'm right. QED.

========
========
=
=
========  From: David Pollak

On 12/7/07, Jason Dusek  wrote:
> David Pollak  wrote:
> > Both have methods to invoke the functions (Scala calls this
> > method "apply" and Ruby calls it "call").  The Scala compiler
> > will convert f() to f.apply() if f is a subclass of Function,
> > but that's syntactic sugar on top of the Object wrapper.
>
> That's part of the answer -- but how do you define functions in
> Scala? Is Scala function definition in the world of statements
> or the world of expressions?

This is not part of the answer.  The syntax of creating a
function is immaterial as to the ability to, for example, do
Church Encoding.

Incomplete — will finish transferring convo later.

Function & Actions

A function defines a relation between values, namely the input values and the output values. This relation is timeless.

An action is a sequence of instructions. Whatever relations can be derived from these instructions are accidental and subject to change — there’s not relying on them.

One approach to functions and actions that I like is functions that return actions.

Uses Of Socks

Socks keep your feet worm, but wearing them also keeps your sandals clean. Tile and hardwood floors are kept dry by frequent sockage, especially helpful in the kitchen. I wish I could wear socks everyday; but socks which are light enough to wear in the summer get dirty looking too fast.

Doing Something

Today, I accomplished nothing. I ate some food, read, and talked on the phone. I tried to install a filesystem — I want some kind of, any kind of, union file system for linux — and can only arrange for a system that fails on newer kernels.

A Little Exercize Before Eating…

…opens the abdomen to receive the food.

We Just Don’t Need Email Anymore

We can use chat instead. Everytime a new topic is started, it get’s a channel. These channels are saved on the server, and people may join or not — or read the archives. You don’t need to send email to the people. Just give them permission to join the channel, and next time they log in, it will show up on their new list.

Mr. Vig & The Nun

Saw The Monastery today, a guileless film.

From the film, I gathered that Russian nuns have ‘first prayer’ at 00:00 for an hour, go to sleep and wake right up at 05:30 to rock out until 10:00, when they break for work. They eat at 11:00 and after that, work, until more prayer time. Are afternoon naps allowed? This morning, I slept from 01:00 to 11:00.

Soldiers’ Rights

A sad matter:

http://alternet.org/waroniraq/66160/

The actions of the troops, I applaud. But why are they there? What freedom exists in a nation whose citizens are compelled, against their own will and the good sense of their countrymen, to endanger their lives in an empty war? It is by luck that I, a fit man of 26 years, am not in their position, torn between “orders” and prudence.

By staying out of the way, the troops not only save their skins, but discourage the insurgents — there’s fewer opportunities to shoot at Americans, and less reason to. When merely there, our troops are a stabilizing force; but when active, they are destabilizing, stirring up the hornets.

There needs to be official recognition of “soldiers’ rights” — the circumstances under which soldiers can say “fuck off” and go the fuck home should be well protected by the state’s contract with them.

Lily Turns The Crank

At Farmers’ Market today, I helped to run the apple press. We had a press with a grinder/feed mechanism. You turned a big crank to grind up the apples, spitting them into a bucket. When the bucket was full, it was time for the pressing — a plate went over the bucket, and another crank engaged to squish out the juice.

Volunteers came and went at the press. Some fed the apples into the chute, some turned the press; but most turned the crank while I braced the machine and dumped in apples. Lily — about ten years old — started by feeding the chute. She was around for awhile, with her dad; she left and then came back by herself. She turned the crank and turned the crank — for quite some time — and went back to feeding the chute while I braced the press and someone else turned the crank. “What’s your name, brother man?” Lily did a double take. “Lily”, she said, quietly. I thought about this for a minute or two, waited for the crowd to thin, and apologized to Lily. “I don’t know many young people.”, I said, “I sometimes can’t tell girls from boys.”. Lily went back to the crank and people commented on her vigour. “Yeah, she’s great!”, I said — I didn’t want anyone else to make the same mistake, and I wanted Lily to know I had taken my apology to heart.

I gender children on the basis of what I think their parents want them to look like. Lily, in mottled gray pants, a plain colored tea shirt and bright orange sandals, with a short haircut, seemed boyish enough. Her dad mentioned her name once or twice; but I took it as “Lionel”, since I had already made up my mind.

One of the other staffers though Lily was a little boy, too, so I’m not alone in my error. I wonder how this will effect Lily as she transitions into adolescence?