# Programming Languages As Essays Of Elia

### Implicit parameters

Data type for implicit parameters is a tuple of the value together with a lookup function that returns the value of an implicit parameter with the given name:

The function returns the value (and ignores the implicit parameters). In , we duplicate the implicit parameters into and , we call the function with the first set and we return a comonad with the resulting value and the second set of implicit parameters:

The operation combines the two lookup functions it gets and creates two copies. We also need a special function to get the value of an implicit parameter:

The coeffect annotations tell us what implicit parameters are available and all the operations of the coeffect algebra are $$\cup$$.

### Dataflow computations

Data type for dataflow computations is a non-empty list, but to keep the example simpler, we'll write it just as a list:

The operation returns the head, which is why we need a non-empty list! The operation takes a list and produces a list of the same length. It is done by applying to all the suffixes:

produces . The operation is and simply duplicates the list. A special operation shifts the list by 1 element to the past:

The coeffect annotations represent the number of past values needed. When you write , you don't need any past values (just the current one), but when you say , you're accessing one past value. In the coeffect algebra, $${\color{coeff}{\circledast}}, {\color{coeff}{\wedge}}, {\color{coeff}{\oplus}}$$ are $$+, \text{min}, \text{max}$$.

Multiple items
union case IP.IP: 'a * (string -> obj) -> IP<'a>

--------------------
type IP<'a> = | IP of 'a * (string -> obj)

Full name: Document.IP<_>

Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string

type obj = System.Object

Full name: Microsoft.FSharp.Core.obj

val counit : IP<'a> -> 'a

Full name: Document.counit

val v : 'a

val cobind : f:(IP<'a> -> 'b) -> IP<'a> -> IP<'b>

Full name: Document.cobind

val f : (IP<'a> -> 'b)

val p : (string -> obj)

val p1 : (string -> obj)

val p2 : (string -> obj)

val lookup : name:string -> IP<'a> -> obj

Full name: Document.lookup

val name : string

val f : (string -> obj)

Multiple items
union case DF.DF: 'a list -> DF<'a>

--------------------
type DF<'a> = | DF of 'a list

Full name: Document.DF<_>

type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>

val counit : DF<'a> -> 'a

Full name: Document.counit

val cobind : f:(DF<'a> -> 'b) -> _arg1:DF<'a> -> DF<'b>

Full name: Document.cobind

val f : (DF<'a> -> 'b)

val x : 'a

val xs : 'a list

val tl : 'b list

val prev : DF<'a> -> DF<'a>

Full name: Document.prev

val vs : 'a list

### Implicit parameters

Let's start by looking at a few examples that use implicit parameters. The first one is already loaded and translated!

Code to access an implicit parameter is translated into a call to the function. The values that you enter in the user interface are passed in as a special value.

When you use multiple implicit parameters, the primitive is used to divide the context between and . Each will contain only the required parameters.

When we define a function, the input context is first merged with the one that is attached to the input of the function. The variable is in the source, but in the translation. All parameters are required from the caller and they are kept with the input of the function.

This is the most interesting case, because is bound locally, but needs to be defined when the function is called later.

The first line is not interesting, but the second one defines which combines all parameters (there are none) with a new assignment for . The function then merges with - the first one contains the value for and the other one stores the value for . After that, the context is split again and we access both of the parameters separately.

Load one of the samples on the left (or above) for simple demos, or choose a language and write your own snippet!

In the formatted code below, you can see types of variables in a tooltip. Curried functions with multiple parameters and function defined using are expanded.

### Flat dataflow

The translation for the flat dataflow is the same as for implicit parameters. One thing we did not discuss before is the handling of variables:

Variables are passed around in a tuple in the value and they are extracted using together with and to find the right one.

The keyword is mapped to the operation, which turns a comonad value with $$n$$ past values into one with $$n-1$$ past values (dropping the current value).

In flat dataflow, we keep one annotation for the whole context, because we need the same number of past values for all the variables in the context. They are all just elements of one big tuple!

Now you can see why we need 1 past value of both and . We first merge all the variables into a single context value . Because we then need 1 past value of the variable , we also end up requiring 1 past value of . This is because behaves like and it needs two lists of the same length.

### Structural dataflow

In structural dataflow, things work a bit differently. We have annotations for individual variables in the context. For example, a context containing and where we need the current value of and one value of will be represented as :

The variables and are merged into . The initial context is now and it contains empty tuple of variables with empty vector of annotations written as . To select a subset of variables from a context, we're now using a family of operations where the subscript denotes which of the variables from the context we want to extract ( means keep, means drop).

The place where things become really interesting is when we have function application. The following calls a helper function that accesses the previous value of its argument on a previous value of :

We need two past values of and one past value of . In the translation, the value carries two past values of . The function is then called with an argument produced by . Here, both and need to have one past value and adds the requirements (this is the $$+$$ in the coeffect algebra)!

Essays of Elia is a collection of essays written by Charles Lamb; it was first published in book form in 1823, with a second volume, Last Essays of Elia, issued in 1833 by the publisher Edward Moxon.

The essays in the collection first began appearing in The London Magazinein 1820 and continued to 1825. Lamb's essays were very popular and were printed in many subsequent editions throughout the nineteenth century. The personal and conversational tone of the essays has charmed many readers; the essays "established Lamb in the title he now holds, that of the most delightful of English essayists."[1] Lamb himself is the Elia of the collection, and his sister Mary is "Cousin Bridget." Charles first used the pseudonym Elia for an essay on the South Sea House, where he had worked decades earlier; Elia was the last name of an Italian man who worked there at the same time as Charles, and after that essay the name stuck.

American editions of both the Essays and the Last Essays were published in Philadelphia in 1828. At the time, American publishers were unconstrained by copyright law, and often reprinted materials from English books and periodicals; so the American collection of the Last Essays preceded its British counterpart by five years.[2]

Critics have traced the influence of earlier writers in Lamb's style, notably Sir Thomas Browne and Robert Burton[3] – writers who also influenced Lamb's contemporary and acquaintance, Thomas De Quincey.

Some of Lamb's later pieces in the same style and spirit were collected into a body called Eliana.[4]

## Essays

The following essays are included in the collection:

• "The South-Sea House"
• "Oxford In The Vacation"
• "Christ's Hospital Five-And-Thirty Years Ago"
• "The Two Races Of Men"
• "New Year's Eve"
• "Mrs Battle's Opinions On Whist"
• "A Chapter On Ears"
• "All Fools' Day"
• "A Quakers' Meeting"
• "The Old and The New Schoolmaster"
• "Valentine's Day"
• "Imperfect Sympathies"
• "Witches And Other Night-Fears"
• "My Relations"
• "Mackery End, In Hertfordshire"
• "Modern Gallantry"
• "The Old Benchers Of The Inner Temple"
• "Grace Before Meat"
• "My First Play"
• "Dream-Children; A Reverie"
• "Distant Correspondents"
• "The Praise Of Chimney-Sweepers"
• "A Complaint Of The Decay Of Beggars In The Metropolis"
• "A Dissertation Upon Roast Pig"
• "A Bachelor's Complaint Of the Behaviour Of Married People"
• "On Some Of The Old Actors"
• "On The Artificial Comedy Of The Last Century"
• "On The Acting Of Munden".

And in Last Essays of Elia:

• "Blakesmoor in H——shire"
• "Poor Relations"
• "Detached Thoughts on Books and Reading"
• "Stage Illusion"
• "To the Shade of Elliston"
• "Ellistoniana"
• "The Old Margate Hoy"
• "The Convalescent"
• "Sanity of True Genius"
• "Captain Jackson"
• "The Superannuated Man"
• "The Genteel Style of Writing"
• "Barbara S——
• "The Tombs in the Abbey"
• "Amicus Redivivus"
• "Some Sonnets of Sir Philip Sidney"
• "Newspapers Thirty-Five Years Ago"
• "Barrenness of the Imaginative Faculty in the Productions of Modern Art"
• "The Wedding"
• "Rejoicings upon the New Year's Coming of Age"
• "Old China"
• "The Child Angel; a Dream"
• "Confessions of a Drunkard"
• "Popular Fallacies".

Among the individual essays, "Dream-Children" and "Old China" are perhaps the most highly and generally admired.[5] A short musical work by Elgar was inspired by "Dream-Children". Lamb's fondness for stage drama provided the subjects of a number of the essays: "My First Play," "Stage Illusion," Ellistoniana," etc. "Blakesmoor in H——shire" was actually written about Blakesware in Hertfordshire, the great house where Lamb's maternal grandmother was housekeeper for many years.[6]