generic programming for domain reasoners · generic programming for domain ... linear equations, or...

42
Chapter 1 Generic programming for domain reasoners Johan Jeuring,1,2 Jose ´ Pedro Magalh˜a es,1 Bastiaan Heeren2 Category: E valuation Abstract: An exercise assistant is a tool that supports students learning p roce- dural skills, such as solving systems of linear equations, or rewriting a logic ex- pression to disjunctive normal form. The domain reasoner is the component of an exercise assistant that deals with tasks that depend on the semantics of a p articular domain. An exercise assistant typically has multiple domain r easoners, and the behavior of each of these is, to a large extent, determined by the domain. Generic programming techniques claim to reduce code duplication, to make

Upload: dangdiep

Post on 29-Aug-2018

254 views

Category:

Documents


1 download

TRANSCRIPT

Chapte

r1

Gen

eric

prog

ram

min

gfo

rdo

mai

nre

asoners

Joh

an

Jeuri

ng,1,

2Jo

se ´

Ped

roMa

galh˜a

es,1

Ba

stia

an

Heere

n2C

ate

go

ry:

E v

alu

atio

n

Abs

trac

t:A

nex

erci

seas

sist

ant

isa

tool

that

supp

orts

stud

ents

lear

ning

p ro

ce-

dura

lsk

ills,

such

asso

lvin

gsy

stem

sof

linea

req

uatio

ns,

orre

writ

ing

alo

gic

ex-

pres

sion

todi

sjun

ctiv

eno

rmal

form

.Th

edo

mai

nre

ason

eris

the

com

pone

ntof

anex

erci

seas

sist

ant

that

deal

sw

ithta

sks

that

depe

ndon

the

sem

antic

sof

ap

artic

ular

dom

ain.

An

exer

cise

assi

stan

tty

pica

llyha

sm

ultip

ledo

mai

nr e

ason

ers,

and

the

beha

vior

of

each

of

thes

eis

,to

ala

rge

exte

nt,

dete

rmin

edby

the

dom

ain.

Gen

eric

prog

ram

min

gte

chni

ques

clai

mto

redu

ceco

dedu

plic

atio

n,to

mak

e

itea

sier

toch

ange

the

stru

ctur

eof

data

and

topr

ovid

eim

plem

enta

tions

of

man

yus

eful

func

tions

onm

ost

data

type

s.Th

ere

are

man

ylib

rarie

sfo

rge

neric

prog

ram

-m

ing,

all

with

diffe

rent

data

type

supp

ort,

expr

essi

vene

ssan

dea

seof

use.

W h

ilea

lot

of

effo

rtha

sbe

enpu

tin

tode

velo

ping

new

libra

ries

inth

ep

ast

few

year

s,th

ere

are

few

exam

ples

of

real

life

appl

icat

ions

of

gene

ricp

rogr

amm

ing.

Inth

ispa

per,

we

desc

ribe

our

expe

rienc

eof

appl

ying

gene

ricp

rogr

amm

ing

tech

niqu

esto

our

dom

ain

reas

oner

sim

plem

ente

din

Has

kell.

We

asse

ssan

dco

mpa

reth

ere

-su

lting

gene

ricdo

mai

nre

ason

ers

with

each

othe

ran

dw

ithth

ein

itial

,no

n-ge

neric

vers

ion,

u si

ngth

eso

ftwar

equ

ality

fact

ors

of

the

ISO

9126

inte

rnat

iona

lst

anda

rd.

1.1

INT

RO

DU

CT

ION

An

exer

cise

assi

stan

the

lps

ast

uden

tw

ithso

lvin

gex

erci

ses,

for

exam

ple

toso

lve

equa

tions

,or

dete

rmin

eth

ede

rivat

ive

of

afu

nctio

n.Th

ere

exis

thu

ndre

dsofe

xer-

cise

assi

stan

ts,

for

man

ym

athe

mat

ical

dom

ains

:lo

gic,

phys

ics,

etc.

An

impo

rtant

1Uni

vers

iteit

Utre

cht,

Dep

artm

ent

ofIn

form

atio

nan

dC

ompu

ting

Scie

nces

,PO

Box

80.0

89,

3508

TBU

trech

t,Th

eNe

ther

land

s2O

pen

Uni

vers

iteit

Ned

erla

nd,

Scho

olof

Com

pute

rSc

ienc

e,PO

Box

2960

,64

01D

LH

eerle

n,Th

eN

ethe

rland

s;{j

ohan

j,jp

m,

ba

stia

an}@

cs.u

u.n

l

1

2C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FO

RD

OM

AIN

RE

AS

ON

ER

S

part

of

anex

erci

seas

sist

ant

isth

edo

mai

nr e

ason

er:

aco

mpo

nent

whi

chtra

cks

the

step

sth

est

uden

tta

kes,

give

shi

nts,

diag

nose

ser

rors

,re

cord

sp

rogr

ess,

show

sw

orke

d-ou

tso

lutio

ns,

etc.

The

func

tiona

lity

of

the

dom

ain

reas

oner

fund

amen

-ta

llyde

pend

son

the

dom

ain,

the

rule

sth

ath

old

for

the

dom

ain

and

the

stra

tegi

esfo

rso

lvin

gex

erci

ses

with

inth

edo

mai

n.Th

eco

reco

mpo

nent

sof

ado

mai

nre

ason

erar

e:

•A

desc

riptio

nof

the

dom

ain,

cons

istin

gof

anab

stra

ctsy

ntax

toge

ther

with

apa

rser

arnipd

ta

pret

ty-p

rinte

r.

•R

ules

with

whi

chex

pres

sion

sin

the

dom

ain

are

man

ipul

ated

.Fo

rex

ampl

e,fRo

urleth

sewdo

itmhwa

ihnof

logi

cex

pres

sion

s,ethd

eoodm

isatirin

ba utri

eonm

r aunlie

pux

∨lat(ey

d∧.zF

)re

(xxa∨m

yp)l

e∧,(fox

rr∨th

z)e,d

Dome

Mor

gan’

silca

wex

p¬r(ex

ss∨i

oy)n

s , t

¬x

∧is¬

y,uet

tico.

•St

rate

gies

for

solv

ing

exer

cise

sin

the

dom

ain.

For

exam

ple,

for

r ew

ritin

ga

tSetrrm

ateign

iteos

disj

unct

ive

n eoxr

emrca

ilsfeo

sr min:

hfiers d

tr e

mov

eFBo

rooe lx

eaanm

cons

tant

s,im

plic

a-tio

nsan

deq

uiva

lenc

es,

then

push

nega

tions

insi

de,

and

final

lym

ove

occu

r-

renc

esof

∨up

war

ds.

Add

ition

ally

,fo

rea

chdo

mai

nw

ene

edfu

nctio

nalit

yfo

run

ifyin

gan

dre

writ

ing

term

s,ge

nera

ting

exer

cise

s,tra

vers

ing

term

s,de

term

inin

gth

eto

p-le

vel

equa

lity

of

two

term

s,et

c.In

the

past

few

year

s,w

eha

vede

velo

ped

dom

ain

r eas

oner

sw

hich

help

with

diag

nosi

ngst

uden

tbe

havi

our

inus

ing

exer

cise

assi

stan

tsfo

rca

lcul

atin

gw

ithfra

c-tio

ns,

perfo

rmin

gG

auss

ian

elim

inat

ion,

solv

ing

syst

ems

of

linea

req

uatio

nsan

dot

her

linea

ral

gebr

aex

erci

ses,

fact

orin

gp

olyn

omia

ls,

rew

ritin

ga

logi

cal

term

todi

sjun

ctiv

eno

rmal

form

,r e

writ

ing

rela

tion

alge

bra

term

s,de

velo

ping

(ext

ende

d)la

mbd

aca

lcul

usp

rogr

ams,

and

dete

rmin

ing

the

deriv

ativ

eor

inte

gral

of

afu

nc-

tion

[8,9

,15,

19].

Our

dom

ain

reas

oner

sof

fer

the

func

tiona

lity

desc

ribed

abov

eas

Web

ser-

vice

s[6

].S

ever

alex

erci

seas

sist

ants

,su

chas

Mat

hDox

[5],

Act

iveM

ath

[7]

and

the

Freu

dent

hal

Inst

itute

digi

tal

mat

hem

atic

sen

viro

nmen

t(D

WO

)[3

]us

eou

rdo

-m

ain

reas

onin

gW

ebse

rvic

es.

At

the

mom

ent

we

deve

lop

and

mai

ntai

nou

row

ndo

mai

nr e

ason

ers,

butin

the

futu

rew

eex

pect

user

sof

our

serv

ices

toad

dor

adap

tdo

mai

ns.

Furth

erm

ore,

we

are

invo

lved

intw

ore

cent

lyfu

nded

rese

arch

proj

ects

abou

tbr

idgi

ngth

ekn

owle

dge

gap

inm

athe

mat

ics

betw

een

seco

ndar

ysc

hool

san

dun

iver

sitie

s:M

ath

-brid

ge(f

rom

the

EU

eCon

tent

Plu

sp

rogr

amm

e)an

dN

KB

W2

(fro

mth

eS

UR

FFo

unda

tion,

the

Dut

chhi

gher

educ

atio

nan

dre

sear

chp

artn

ersh

ip

orga

niza

tion

for

ICT

).Fo

rth

ese

proj

ects

we

have

tode

liver

anu

mbe

rof

dom

ain

reas

oner

sea

chye

ar.

Toav

oid

reim

plem

entin

gth

esa

me

func

tiona

lity

for

ever

ydo

mai

nan

dto

sim

-pl

ifyth

epr

oces

sof

crea

ting

ane

wdo

mai

nre

ason

er,

we

have

u se

dge

neric

p ro

-gr

amm

ing

tech

niqu

es[2

]to

impl

emen

tr e

writ

ing,

trave

rsal

s,et

c.on

cean

dfo

ral

ldo

mai

ns.

The

appl

icat

ion

of

gene

ricp

rogr

amm

ing

tech

niqu

esto

our

dom

ain

r ea-

sone

rsis

the

proj

ect

that

we

eval

uate

i nth

isp

aper

:ho

wca

nge

neric

prog

ram

min

gbe

used

ina

larg

e,re

alis

ticap

plic

atio

n?W

hat

are

the

bene

fits

and

the

shor

t-co

min

gsof

the

solu

tion

t hat

u se

sge

neric

prog

ram

min

gte

chni

ques

?W

eex

pect

1.2.

US

ING

GE

NE

RIC

PR

OG

RA

MM

ING

3

gene

ricpr

ogra

mm

ing

tech

niqu

esto

sim

plify

the

addi

tion

of

new

dom

ain

reas

on-

ers

orto

chan

geex

istin

gon

es,

and

tor e

duce

the

code

b as

ean

dco

dedu

plic

atio

n.H

owev

er,

appl

icat

ion

of

gene

ricp

rogr

amm

ing

t ech

niqu

esal

sop

oses

som

ech

al-

leng

es.

We

have

toch

oose

asu

itabl

eap

proa

ch,

with

the

right

expr

essi

vene

ssan

dda

taty

pesu

ppor

t.A

dditi

onal

ly,

we

mus

ten

sure

that

we

can

k ee

pal

lof

the

orig

i-na

lfun

ctio

nalit

y,an

dth

atth

ege

neric

solu

tion

isin

deed

anim

prov

emen

tov

erth

eno

n-ge

neric

vers

ion.

We

have

impl

emen

ted

our

dom

ain

reas

oner

sin

Has

kell.

Initi

ally

,w

ech

ose

Has

kell

beca

use

itis

ala

ngua

gew

efe

elco

mfo

rtabl

ep

rogr

amm

ing

in,

and

be-

caus

edo

mai

nre

ason

ers

man

ipul

ate

expr

essi

ontre

es,

atw

hich

Has

kell

isgo

od.

Late

r,w

hen

we

deci

ded

tom

ake

our

dom

ain

reas

oner

sge

neric

,th

istu

rned

out

tobe

the

right

choi

ce,

sinc

eth

ere

are

man

yap

proa

ches

toge

neric

prog

ram

min

gin

Has

kell

[11,

23].

Type

s(d

omai

ns)

play

anim

porta

ntro

lein

our

softw

are,

and

we

also

wan

tto

use

type

dap

proa

ches

toge

neric

p ro

gram

min

g,w

hich

rule

sou

tan

appr

oach

like

DrI

FT

[24]

and

othe

rap

proa

ches

b as

edon

met

apro

gram

min

gor

code

gene

ratio

n.Th

ees

sent

ial

tech

nolo

gyus

edin

our

dom

ain

reas

oner

sis

rew

ritin

g(to

geth

erw

ithm

atch

ing)

.W

hen

r ew

ritin

g,w

em

ayap

ply

any

rew

ritin

g

rule

atan

ypo

sitio

ni n

ate

rm.

Of

cour

se,

ar e

writ

ing

rule

can

only

b eap

plie

dto

ate

rmw

ithin

the

dom

ain.

Itfo

llow

sth

atw

ene

edto

k no

ww

hich

subt

erm

sof

ate

rmbe

long

toth

edo

mai

nag

ain,

whi

chim

plie

st h

atw

ene

edto

know

the

recu

rsiv

est

ruct

ure

of

the

dom

ain.

Ther

ear

eon

lya

few

gene

ricpr

ogra

mm

ing

libra

ries

inH

aske

llth

atgi

veth

eus

erac

cess

toth

er e

curs

ive

stru

ctur

eof

valu

es:

Uni

plat

e[1

7],

Reg

ular

[18]

and

Mul

tirec

[22]

,in

ast

raig

htfo

rwar

dw

ay,

and

Scra

pY

our

Boi

lerp

late

(SY

B)

[14]

,in

ara

ther

cum

bers

ome

way

(see

the

Uni

plat

em

od-

ule

Dat

a.G

ener

ics.

Pla

teD

ata,

whi

chim

plem

ents

Uni

plat

eu

sing

SY

B).

We

have

thre

eim

plem

enta

tions

of

age

neric

dom

ain

reas

oner

:on

eu

sing

U n

ipla

te,

one

us-

ing

Mul

tirec

and

one

usin

gR

egul

ar.

This

eval

uatio

npa

per

disc

usse

sw

here

and

how

gene

ricpr

ogra

mm

ing

tech

-ni

ques

impa

ctth

equ

ality

of

our

softw

are.

Tost

ruct

ure

the

disc

ussi

on,

we

use

the

qual

itych

arac

teris

tics

defin

edin

the

ISO

9126

[13]

inte

rnat

iona

lst

anda

rdfo

rth

eev

alua

tion

of

softw

are

qual

ity.

We

use

thes

ech

arac

teris

tics

beca

use

they

help

togu

aran

tee

com

plet

enes

san

din

depe

nden

cein

our

com

paris

on.

Whe

nw

edi

scus

sth

ech

arac

teris

tics,

we

will

give

exam

ples

of

how

they

play

aro

lein

our

dom

ain

reas

oner

s.W

ew

illco

mpa

refo

urve

rsio

nsof

our

dom

ain

reas

oner

s:a

vers

ion

with

out

gene

ricp

rogr

amm

ing

tech

niqu

esan

dth

ree

vers

ions

usin

gge

neric

p ro

-gr

amm

ing,

one

for

each

of

the

Uni

plat

e,M

ultir

ecan

dR

egul

arlib

rarie

s.W

eho

peth

atou

rex

perie

nce

can

b eus

edas

are

fere

nce

for

othe

rpr

ojec

tsth

atco

nsid

erus

ing

gene

ricpr

ogra

mm

ing.

1.2

US

ING

GE

NE

RIC

PR

OG

RA

MM

ING

We

have

refa

ctor

edou

rex

istin

gdo

mai

nr e

ason

ers

tosp

litoff

com

pone

nts

that

can

b eim

plem

ente

db

ym

eans

of

gene

ricco

mpo

nent

s.Fo

rex

ampl

e,th

ese

cond

vers

ion

of

our

first

dom

ain

reas

oner

(200

5-20

06)

impl

emen

ted

linea

req

uatio

nsus

ing

the

follo

win

gda

taty

pes:

4C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FOR

DO

MA

IN R

EA

SO

NE

RS

type

Equa

tions

=[E

quat

ion]

data

Equ

atio

n=

Expr

:=:

Expr

data

Expr

=C

onR

atio

nal

|E

Var

Stri

ng||

EExVap

rr: S+

t:Ein

xgpr

||EEx

xpprr

:−:

EExxpp

rr||

EExxpp

rr::−×

::EEx

xpprr

||EEx

xpprr

::×/::

EExxpp

rr

The

dom

ain

reas

oner

cont

aine

dfu

nctio

nalit

yfo

rr e

writ

ing

linea

req

uatio

nsan

dm

athe

mat

ical

expr

essi

ons

that

are

used

ineq

uatio

ns

mod

ule

E q

uatio

nsR

ewrit

eAna

lysi

sw

here

equa

tions

Rew

rite

=..

.ex

prR

ewrit

e=

...

equa

tions

Subs

t=

...

expr

Subs

t=

...

ina

449-

line

mod

ule.

Inou

rcu

rren

tdo

mai

nre

ason

er,

the

dom

ain

of

linea

rex

-pr

essi

ons

does

not

cont

ain

spec

ific

func

tiona

lity

for

r ew

ritin

gan

dsu

bstit

utio

nan

ym

ore.

Inst

ead,

gene

ricfu

nctio

nsfo

rr e

writ

ing

and

subs

titut

ion

are

calle

dw

hen

the

gene

ricdo

mai

nre

ason

eris

u se

don

linea

rex

pres

sion

s.Th

ege

neric

r ew

ritin

gan

dsu

bstit

utio

nfu

nctio

nsth

emse

lves

are

impl

emen

ted

inte

rms

ofb

asic

gene

ricfu

nc-

tions

,su

chas

f old

,zi

p,cr

ush

and

map

[18]

.A

llin

all,

the

gene

ricm

odul

esfo

rre

writ

ing

cons

ist

of

370

lines

.Th

ege

neric

r ew

ritin

gfu

nctio

nalit

yis

used

inal

lot

her

dom

ains

asw

ell.

Ther

ear

ese

vera

lw

ays

inw

hich

gene

ricpr

ogra

mm

ing

can

b eus

edin

our

dom

ain

r eas

oner

s:

•To

obta

inin

stan

ces

of fu

nctio

nsw

hich

natu

rally

depe

ndon

the

stru

ctur

eof

the

data

type

,isnu

schta

astsh

oere

writ

ing

sfw unh

citcihon

n ,abtuu

rtaaall

lysod

eb paes

incddfu

o nnct

htioens

tslik

ef o

lda th

ndem

ap.

•To

use

gene

rictra

vers

alfu

nctio

nsto

appl

yso

me

func

tion

ata

parti

cula

rpo

si-

Ttioon

usine

apo

ssib

lyla

rge

lvf auln

ucetoio

fna

fam

ilyloy

fdat

atyp

es.

•To

not

have

toad

just

man

yfu

nctio

nsw

hen

exte

ndin

gor

r ede

finin

ga

dom

ain.

We

h av

eus

edge

neric

func

tions

for

allo

fth

ese

p ur

pose

s.

1.3

GE

NE

RIC

PR

OG

RA

MM

ING

LIB

RA

RIE

S

Ther

ear

ese

vera

llib

rarie

sfo

rge

neric

p ro

gram

min

gin

Has

kell.

T he

sedi

ffer

sub-

stan

tially

inex

pres

sive

ness

,da

taty

pes

supp

orte

dan

dus

abili

ty.

Rec

ently

,a

de-

taile

dco

mpa

rison

of

gene

ricpr

ogra

mm

ing

libra

ries

has

b ee

npe

rform

ed[2

1,23

].W

eh

ave

used

this

com

paris

onw

hen

choo

sing

age

neric

prog

ram

min

glib

rary

.

1.3.

GE

NE

RIC

PR

OG

RA

MM

ING

LIB

RA

RIE

S5

1.3.

1D

atat

ypes

inth

edo

mai

nre

ason

ers

Our

dom

ain

reas

oner

scu

rren

tlyr e

pres

ent

seve

ral

dom

ains

,su

chas

logi

cex

pres

-si

ons,

rela

tion

alge

bra

and

prog

ram

min

gin

asi

mpl

efu

nctio

nal

lang

uage

.E

ach

dom

ain

isre

pres

ente

dby

one

or

mor

eda

taty

pes.

Topr

ovid

ege

neric

func

tiona

lity

ona

dom

ain,

we

h av

eto

guar

ante

eth

atth

eda

taty

pes

r epr

esen

ting

the

dom

ain

can

betre

ated

gene

rical

ly.

D if

fere

ntlib

rarie

sfo

rge

neric

prog

ram

min

gha

vedi

ffere

ntle

vels

of

supp

ort

for

data

type

s.O

urda

taty

pes

h av

edi

ffere

ntle

vels

of c

ompl

exity

.Th

edo

mai

nofl

ogic

expr

es-

sion

s,fo

rin

stan

ce,

isre

pres

ente

db

ya

sing

le,

r ecu

rsiv

e,no

n-pa

ram

etric

data

type

:

data

Logi

c=

Logi

c:→

:Lo

gic

--im

plic

atio

n=|

Logi

c:↔

:Lo

gic

--eq

uiva

lenc

e||

LLoogg

iicc::∧↔

:LLo

oggiicc

--co

njun

ctio

n(a

nd)

||Lo

gic

::∧∨::

Logi

c--

disj

unct

ion

(or)

||LN

oogtL

ogic

--ne

gatio

n(n

ot)

||VNa

ortLS

otrginic

g--

varia

bles

||VTa

--tru

e

||T F

--fa

lse

The

dom

ains

of

rela

tion

alge

bra,

p ro

gram

min

gan

dca

lcul

atin

gw

ithfra

ctio

nsar

ere

pres

ente

dby

data

type

sof

sim

ilar

com

plex

ity.

Our

repr

esen

tatio

nof

mat

hem

atic

alex

pres

sion

sus

eslis

ts:

data

Expr

=E

xpr

:+:

Exp

r--

addi

tion

|E

xpr

:×:E

xpr

--m

ultip

licat

ion

||EEx

xpprr

:−:

EExxpp

rr--

subt

ract

ion

||N

egat

e:E E

xpxpr

--ne

gatio

n||

ENxegp

rat:/e

:EExx

pprr

--di

visi

on||

Sqr

tE :/

x:pE r

--sq

uare

root

||N S

qarttI

nteg

er--

natu

ral

num

ber

||N E

VaatrI n

nStetg

rinerg

--va

riabl

e||

Sym

rSS trti

rningg

[Exp

r]--

sym

bol

Due

toth

eir

p er

vasi

vene

ssin

Has

kell,

lists

shou

ldbe

give

na

p ar

ticul

artre

atm

ent

byth

ege

neric

prog

ram

min

glib

rary

.F

orin

stan

ce,

we

expe

ctth

eal

gebr

afo

rth

eSy

mco

nstru

ctor

of

the

Exp

rda

taty

peto

have

type

algS

ym::

Str

ing

→[r

]→

r.

This

will

not

h ap

pen

if,f

or

inst

ance

,w

etre

atth

e[E

xpr]

occu

rren

ceas

aco

nsta

ntty

pe. Th

edo

mai

no

fsy

stem

so

flin

ear

equa

tions

uses

afa

mily

of

p ar

amet

ricda

ta-

type

s: type

Line

arS

yste

m=

[Equ

atio

nE

xpr]

data

Equ

atio

na

=a

:=:

a

6C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FO

RD

OM

AIN

RE

AS

ON

ER

S

We

need

the

para

met

ricity

beca

use

we

can

r epr

esen

teq

uatio

nsof

diffe

rent

k in

dsof

expr

essi

ons.

The

dom

ain

for

p ol

ynom

ials

uses

anab

stra

ctda

taty

pe:

new

type

Pol

ynom

ial

a=

P(I

ntM

apa)

Usi

ngab

stra

ctda

taty

pes

incr

ease

sth

eef

ficie

ncy

and

conc

isen

ess

of

the

code

,bu

tpr

eclu

des

the

appl

icat

ion

of

gene

ricpr

ogra

mm

ing

tech

niqu

es.

The

expr

essi

vene

ssof

age

neric

p ro

gram

min

glib

rary

isor

thog

onal

toits

sup-

port

for

data

type

s.So

me

libra

ries

can

expr

ess

mor

ege

neric

func

tions

than

othe

rs.

For

our

dom

ain

reas

oner

s,w

ene

edfu

nctio

nalit

ysu

chas

rew

ritin

g,da

tage

nera

-tio

nan

dfo

ldin

g.Th

iscl

early

r est

ricts

our

choi

ceto

libra

ries

whi

chha

vea

notio

nof

the

recu

rsiv

est

ruct

ure

of

the

data

type

s:U

nipl

ate,

Reg

ular

and

M u

ltire

c.W

eha

veus

edea

chof

thes

eth

ree

libra

ries

atdi

ffere

ntst

ages

inou

rdo

mai

nr e

ason

ers.

We

will

give

abr

ief

over

view

of

each

of

the

libra

ries

and

our

reas

ons

for

u si

ngth

em.

1.3.

2U

nipl

ate

The

Uni

plat

elib

rary

[17]

prov

ides

com

bina

tors

for

gene

rictra

vers

als.

Itis

sim

ilar

inst

yle

toS

YB

,bu

tsi

mpl

ersi

nce

itdo

esno

tus

era

nk-2

poly

mor

phis

m.

Inth

esi

mpl

ified

vers

ion

we

use

for

our

dom

ain

r eas

oner

s,it

cons

ists

ofa

sing

lefu

nctio

nin

aty

pecl

ass:

clas

sU

nipl

ate

aw

here

unip

late

::a→

([a],

[a]→

a)

The

unip

late

func

tion

prov

ides

aw

ayto

acce

ssth

eim

med

iate

child

ren

of

ate

rm(th

efir

stco

mpo

nent

of th

er e

sult

p ai

r)an

dto

rebu

ilda

term

usin

ga

list

of re

plac

e-m

ent

child

ren

(the

seco

ndco

mpo

nent

of th

ep

air).

Eve

ryty

peto

beus

edw

ithth

islib

rary

has

tob e

give

nan

inst

ance

of

the

clas

sU

nipl

ate.

W e

show

part

of

the

inst

antia

tion

for

the

Logi

cda

taty

pe:

inst

ance

Uni

plat

eLo

gic

whe

reun

ipla

te(p

:→

:q)

=([

p,q]

,λ[p

,q]→

p:→

:q)

unip

late

((pp:↔

:q)

==..

...

.

The

othe

rco

nstru

ctor

sha

vea

sim

ilar

defin

ition

.G

ener

icfu

nctio

nsin

Uni

plat

ear

ew

ritte

nus

ing

the

unip

late

com

bina

tor.

The

func

tion

trans

form

b el

ow,

for

i nst

ance

,ap

plie

sa

trans

form

atio

nfu

nctio

non

ever

ysu

bele

men

to

fa

term

ina

botto

m-u

pfa

shio

n:

trans

form

::(U

nipl

ate

a)⇒

(a→

a)→

a→

atr

ansf

orm

fa

=n

ilpelta

(tceh a

i)ld⇒ re

n( ,a

ab→u il

da e)r

→)→=

aun

ipla

tea

in f

$bu

ilder

$m

ap(t

rans

form

f )ch

ildre

n

1.3.

GE

NE

RIC

PR

OG

RA

MM

ING

LIB

RA

RIE

S7

Inth

isfu

nctio

n,ch

ildre

nst

ands

for

the

r ecu

rsiv

ech

ildre

nof

the

inpu

tte

rm,

and

build

eris

the

func

tion

that

,giv

ena

list

ofr

epla

cem

ent

child

ren,

rebu

ilds

the

inpu

tte

rmb

yre

plac

ing

itsch

ildre

nw

ithel

emen

tsfr

omth

elis

t.B

oth

are

com

bine

dto

appl

yth

etra

nsfo

rmat

ion

funct

ionf

toev

ery

r ecu

rsiv

eel

emen

toft

hein

put

term

.W

eus

edU

nipl

ate

asth

efir

stge

neric

p ro

gram

min

glib

rary

inou

rdo

mai

nre

a-so

ners

.Its

sim

plic

ityal

low

edfo

rea

syin

tegr

atio

nan

dim

plem

enta

tion

offu

nctio

n-al

itysu

chas

top-

leve

leq

ualit

yan

da

form

of

rew

ritin

g.H

owev

er,

func

tiona

lity

such

asda

tage

nera

tion

or

fold

ing

cann

otb e

expr

esse

din

Uni

plat

e.

1.3.

3M

ulti

rec

Mul

tirec

[22]

isa

rece

ntly

deve

lope

dge

neric

prog

ram

min

glib

rary

.It

has

the

uniq

ueab

ility

tore

pres

ent

mut

ually

r ecu

rsiv

eda

taty

pes

ina

fixed

-poi

ntvi

ew,

ther

efor

eal

low

ing,

for

inst

ance

,th

ede

finiti

onof

gene

ricfo

lds

onm

utua

llyre

-cu

rsiv

eda

taty

pes.

Itis

base

don

the

r epr

esen

tatio

nof

the

patte

rnfu

ncto

rof

afa

mily

of

type

s,us

ing

type

fam

ilies

.C

onsi

der

apo

ssib

ler e

pres

enta

tion

for

the

dom

ain

of

prog

ram

min

gin

asi

mpl

efu

nctio

nal

lang

uage

:

data

LExp

r=

L am

bda

Stri

ngLE

xpr

|L

Var

Stri

ng||

A pp

lyLtE

rixngpr

LExp

r||

AF pixp

LlyE LxE

pxr||

FL iInx

tLIEn

tx||

LL Ient

tD Ien

tclLE

xpr

data

Dec

l=

Stri

ng:=

LExp

r|

Seq

Dec

lD

ecl

Toill

ustra

teth

ege

neric

r epr

esen

tatio

nus

edby

Mul

tirec

,w

esh

owth

epa

ttern

func

tor

ofth

isfa

mily

ofm

utua

llyre

curs

ive

data

type

s:

data

AS

T::

∗→

∗w

here

LtaE Axp

SrT::

:A:∗S

→TL ∗E

wxphre

Dec

l::

AS

TD

ecl

type

inst

ance

PF

AS

T=

(C

Lam

bda

(KS

tring

:×:I

LExp

r):+

:CC

LLVama

rb((K

KSS

ttrriinn

gg) :

:+:

CA

pply

(ILE

xpr

:×:I

LExp

r):+

:C

Fix

((IILLE

Exxppr

r):+

:C

LInt

(KIn

t)

:+:

CLe

t(I

Dec

l:×

:ILE

xpr)

):.

:LE

xpr

:+:

(C

Ass

ign

(KS

trin

g:×

:ILE

xpr)

:+:

CSe

q((IK

D Setc

ril:×

:IILDE

exclp)r

):.

:D

ecl

Her

e,A

ST

isan

auxi

liary

data

type

defin

edto

r epr

esen

tth

efa

mily

.In

itspa

ttern

func

tor

PF,

sum

s(:

+:)

and

prod

ucts

(:×

:)en

code

the

choi

cebe

twee

nal

tern

ativ

e

8C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FO

RD

OM

AIN

RE

AS

ON

ER

S

cons

truct

ors

and

mul

tiple

argu

men

tst o

aco

nstru

ctor

,r e

spec

tivel

y.C

onst

ruct

ors

are

enco

ded

b y

C,c

onst

ant

type

s(o

utsi

deth

efa

mily

)b

yK

and

recu

rsiv

eoc

cur-

renc

es(ta

gged

with

the

recu

rsiv

et y

pe)

b y

I.A

grou

pof

alte

rnat

ives

belo

ngin

gto

asi

ngle

data

type

ista

gged

with

:.:.

Als

one

cess

ary

are

the

conv

ersi

onfu

nctio

nsto

and

from

the

orig

inal

data

type

sin

toth

ege

neric

view

:

inst

ance

Fam

AS

Tw

here

from

LExp

r(L

ambd

as

e)=

L(T

ag(L

(C(K

s:×

:I(I∗

e)))

))fr

om..

.

toLE

xpr

(L(T

ag(L

(C(K

s:×

:I(I∗

e))

))))

=L

ambd

as

ettoo

...

Not

eth

atth

ere

curs

ive

occu

rrenc

esne

edto

b ew

rapp

edin

the

I ∗co

nstru

ctor

be-

caus

eof

the

high

erki

ndof

theI

cons

truct

or.

We

used

Mul

tirec

inou

rse

cond

vers

ion

of th

ege

neric

dom

ain

reas

oner

sto

in-

crea

seth

eex

pres

sive

ness

.W

ith

Mul

tirec

we

can

writ

ege

neric

fold

san

dda

taty

pege

nera

tion,

asw

ella

san

impr

oved

r ew

ritin

gm

echa

nism

.H

owev

er,

Mul

tirec

can-

not

repr

esen

tpa

ram

etric

data

type

ssu

chas

Equ

atio

n,or

data

type

sw

ithlis

tssu

chas

Exp

r(S

ectio

n1.

3.1)

3.Th

isre

duce

sth

enu

mbe

rof

dom

ains

onw

hich

we

can

use

gene

ricp

rogr

amm

ing.

1.3.

4R

egul

ar

The

Reg

ular

libra

ryis

the

unde

rlyin

gm

echa

nism

of

the

rew

ritin

gfra

mew

ork

de-

scrib

edby

Van

Noo

rtet

al.

[18]

.It

can

bese

enas

asi

mpl

ifica

tion

of

Mul

tirec

,re

pres

entin

ga

sing

lety

peat

atim

e:

type

inst

ance

PF

Logi

c=

CIm

pl(I

:×:I

)--

impl

icat

ion

: +=:C

CIEm

qpuliv

((II:×

:II))

--eq

uiva

lenc

e::++

::CC

CEoqu

nji((II

:×:I

I))--

conj

unct

ion

(and

)::++

::CC

DCoisn

j((II

:×:I

I))--

disj

unct

ion

(or)

:+:

CN

otI(

--ne

gatio

n(n

ot)

:+:

CV

ar(K

Str

ing)

--va

riabl

es:+

:C

TU

--tru

e:+

:C

FU

--fa

lse

inst

ance

Reg

ular

Logi

cw

here

from

(p:→

:q)

=L

(I p

:×:I

q)fr

om..

.

toL

(I p

:×:I

q)=

p:→:

qttoo

...

3As

we

men

tione

dp

revi

ousl

y,w

ew

ant

totre

atlis

tsas

asp

ecia

lca

se.

We

coul

dre

pre-

sent

ada

taty

pew

ithlis

tsin

Mul

tirec

b y

cons

ider

ing

a(m

onom

orph

ic)

list

data

type

asbe

ing

part

of

the

fam

ily,

but

this

chan

ges

the

sem

antic

so

fth

ege

neric

f unc

tions

.F

orex

ampl

e,th

eal

gebr

asfo

rth

efo

ldb

ecom

ele

ssna

tura

l.

1.4.

QU

ALI

TY

CH

AR

AC

TE

RIS

TIC

S9

The

patte

rnfu

ncto

rre

pres

enta

tion

issi

mpl

erth

anin

Mul

tirec

,si

nce

we

nolo

nger

requ

ireta

ggin

gof

recu

rsiv

eoc

curr

ence

s.R

egul

ardo

esno

tsu

ppor

tpa

ram

etric

data

type

sor

data

type

sco

ntai

ning

lists

.H

owev

er,

we

h av

ein

vest

igat

edth

epo

ssib

ility

of

chan

ging

the

libra

ryto

add

sup-

port

forp

aram

eter

s[1

0]an

dfu

ncto

rco

mpo

sitio

n(o

fwhi

chda

taty

pes

with

lists

are

asp

ecia

lca

se).

Bot

hex

tens

ions

seem

poss

ible

and

dono

tle

adto

muc

hin

crea

sed

code

com

plex

ity.

Afte

rh

avin

gus

edM

ulti

rec,

we

real

ized

our

dom

ain

reas

oner

sw

ould

bene

fitm

ore

from

supp

ortin

gpa

ram

eter

san

dda

taty

pes

with

lists

than

from

supp

ortin

gfa

mili

es.

Mor

eove

r,th

eR

egul

arlib

rary

isea

sier

tou

se.

1.4

QU

ALIT

YC

HA

RA

CT

ER

IST

ICS

The

ISO

9126

inte

rnat

iona

lst

anda

rdin

trodu

ces

aqu

ality

mod

elfo

rth

eev

alua

tion

ofs

oftw

are

qual

ity.

This

mod

ellis

tssi

xch

arac

teris

ticar

eas

ofi

mpo

rtanc

e.W

eus

eth

isse

tof

char

acte

ristic

sto

stru

ctur

eou

rdi

scus

sion

onth

equ

ality

char

acte

ristic

sof

our

dom

ain

reas

oner

s.

Fun

ctio

nalit

y:W

eha

vesp

litoff

seve

ral

com

pone

nts

from

the

indi

vidu

aldo

-m

ain

reas

oner

sto

b ere

plac

edby

gene

ricco

mpo

nent

s.Th

isha

sm

ade

itcl

ear

whi

chfu

nctio

nalit

yis

com

mon

toal

ldom

ains

,an

dw

hich

func

tiona

lity

issp

ecifi

cto

ap

artic

ular

dom

ain.

Exa

mpl

esof

gene

ricco

mpo

nent

sar

eth

ef o

ldfu

nctio

n,fu

nctio

nsfo

rre

writ

ing

and

mat

chin

g,fu

nctio

nsfo

rge

nera

ting

arbi

trary

term

s,et

c.S

plitt

ing

off

gene

ricco

mpo

nent

sle

ads

toan

incr

ease

dse

para

tion

of

con-

cern

s:im

prov

emen

tsin

rew

ritin

gfu

nctio

nalit

yar

eso

lved

inth

er e

writ

ing

com

-po

nent

and

lead

toim

prov

emen

tsin

r ew

ritin

gfo

rev

ery

dom

ain.

Furth

erm

ore,

the

func

tiona

lity

oft

hege

neric

com

pone

nts

can

now

beus

edby

othe

rap

plic

atio

nsas

wel

l.In

addi

tion

toth

ege

neric

com

pone

nts

ther

eis

dom

ain-

spec

ific

func

tiona

l-ity

,fo

rex

ampl

efu

nctio

nalit

yfo

rde

term

inin

gth

ese

man

tics

of

anex

pres

sion

inth

edo

mai

n.O

urfir

stge

neric

varia

ntoft

hedo

mai

nr e

ason

ers

u se

dU

nipl

ate

for

the

gene

ricfu

nctio

nalit

y.U

nipl

ate

allo

wed

usto

spec

ifyre

writ

ing

and

trave

rsal

sge

neric

ally

.H

owev

er,

itssi

mpl

icity

limits

itsfu

nctio

nalit

y.In

Uni

plat

eon

eca

nnot

writ

ege

neric

func

tions

that

b ui

ldva

lues

from

scra

tch.

Inbo

thM

ultir

ecan

dR

egul

arw

eca

nw

rite

gene

ricQ

uick

Che

ck[4

]A rb

itrar

yin

stan

ces,

whi

char

eus

edto

gen-

erat

eex

erci

ses

and

test

data

,w

here

asus

ing

Uni

plat

ew

eca

nnot

.U

nipl

ate

also

cann

otde

fine

the

gene

ricfo

ld,

orev

ento

p-le

vel

equa

lity.

Bot

hM

ultir

ecan

dR

eg-

ular

supp

ort

the

defin

ition

of

thes

efu

nctio

ns.

Mul

tirec

supp

orts

fam

ilies

of

(pos

sibl

ym

utua

llyr e

curs

ive)

data

type

s.W

eha

vefa

mili

esof

data

type

sin

som

eof

our

dom

ain

reas

oner

s,bu

tcu

rren

tlyw

edo

not

need

acce

ssto

the

recu

rsiv

est

ruct

ure

of

afa

mily

of

type

s:in

gene

ral,

we

can

focu

son

asi

ngle

type

and

treat

allt

heot

her

occu

rrin

gty

pes

asco

nsta

nts.

For

inst

ance

,fo

rth

edo

mai

nre

ason

erof

syst

ems

of

linea

req

uatio

nsde

scrib

edin

Sec-

tion

1.3.

1w

eon

lyha

vere

writ

eru

les

for

the

Equ

atio

nsan

dno

tfo

rLi

near

Sys

tem

s.H

owev

er,

havi

ngsu

ppor

tfo

rfa

mili

esof

data

type

sm

ight

b ede

sira

ble

inge

nera

l.

10C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FO

RD

OM

AIN

RE

AS

ON

ER

S

We

coul

dde

scrib

eou

rdo

mai

nfo

rsi

mpl

efu

nctio

nal

p ro

gram

min

gb

yth

eLE

xpr

and

Dec

lda

taty

pes

show

nin

Sec

tion

1.3.

1.N

eith

erU

nipl

ate

nor

Reg

ular

can

rep-

rese

ntth

ere

writ

eru

lefo

rin

linin

gin

this

dom

ain,

Let

(x:=

e)(L

Var

x )

e,si

nce

itre

quire

sm

atch

ing

of

b ot

hex

pres

sion

san

dde

clar

atio

ns.

Cur

rent

ly,

our

dom

ain

for

sim

ple

func

tiona

lpr

ogra

mm

ing

treat

sle

tde

clar

atio

nsas

synt

actic

suga

r,an

dw

eth

eref

ore

dono

tne

edth

eab

ove

mut

ually

recu

rsiv

eda

taty

pes.

Usi

ngM

ultir

ec,

how

ever

,w

ould

allo

wfo

rsu

cha

chan

gein

the

futu

re.

The

curr

ent

vers

ion

ofM

ultir

echa

sno

supp

ort

for

type

varia

bles

.Th

edo

mai

nre

ason

erfo

rsy

stem

sof

equa

tions

uses

para

met

eriz

edda

taty

pes,

asw

eha

vese

enin

Sec

tion

1.3.

1.W

eex

pect

supp

ort

for

para

met

ricda

taty

pes

tob e

avai

labl

ein

Mul

tirec

soon

,bu

tfo

rno

ww

eca

nnot

use

iton

this

p ar

ticul

ardo

mai

nre

ason

er.

For

Reg

ular

,th

eex

tens

ion

nece

ssar

yto

supp

ort

p ar

amet

ricda

taty

pes

ism

ore

orle

ssst

raig

htfo

rwar

d,an

dde

scrib

edin

deta

ilb

yH

esse

link

[10]

.

Rel

iabi

lity:

The

gene

ricdo

mai

nre

ason

ers

are

mor

ere

liabl

eth

anth

eor

igin

aldo

-m

ain

r eas

oner

s.O

ner e

ason

isth

atth

ege

neric

dom

ain

reas

oner

sm

ake

mor

eus

eof

libra

ryco

de,

whi

chis

gene

rally

mor

ere

liabl

eth

anda

taty

pe-s

peci

ficco

de.

Fur

-th

erm

ore,

the

orig

inal

dom

ain

r eas

oner

sco

ntai

ned

som

ead

h oc

,an

dso

met

imes

dang

erou

s,so

lutio

ns,

whi

chha

vebe

enre

mov

edin

the

gene

ricdo

mai

nre

ason

ers.

An

exam

ple

of

ada

nger

ous

solu

tion

isth

ew

ayin

whi

chm

etav

aria

bles

wer

ein

trodu

ced

and

used

inth

eor

igin

aldo

mai

nre

ason

ers.

Tode

scrib

ere

writ

ing

r ule

son

the

dom

ains

,th

eva

riabl

esof

the

dom

ains

them

selv

esw

ere

u se

das

met

avar

i-ab

les.

This

was

impl

emen

ted

usin

ga

type

clas

s:

clas

sM

etaV

ara

whe

rem

etaV

ar::

Int→

ais

Met

aVar

::a

→→

Maa

ybe

Int

The

inst

antia

tion

for

the

dom

ain

of

logi

cex

pres

sion

s,fo

rin

stan

ce,

r epr

esen

ted

met

avar

iabl

esas

varia

bles

with

apa

rticu

lar

nam

e:

inst

ance

Met

aVar

Logi

cw

here

met

aVar

n=

Var

("_"

++

show

n)

isM

etaV

ar(V

ar(’

_’:s

))|¬

(nul

ls)

∧a

llis

Dig

its

=ar

r( e’tu

_r’n

:(sr)e)a

|d ¬¬s)

(is

Met

aVar=

Not

hing

Oth

erdo

mai

nsha

dsi

mila

rin

stan

ces.

This

led

toth

epo

ssib

lyda

nger

ous

situ

-at

ion

inw

hich

ado

mai

n-le

vel

varia

ble

coul

db e

conf

used

with

ar e

writ

ing

r ule

met

avar

iabl

e.A

dditi

onal

ly,

this

only

wor

ksfo

rdo

mai

nsw

hich

have

ano

tion

of

varia

bles

.Th

eab

ove

solu

tion

ispa

rtof

the

dom

ain

reas

oner

sth

atus

eU

nipl

ate.

Usi

ngei

ther

Mul

tirec

orR

egul

ar,

we

repr

esen

tm

etav

aria

bles

atth

ege

neric

stru

ctur

ere

p-re

sent

atio

nle

vel.

The

type

syno

nym

Sche

me

tr e

pres

ents

anal

tern

ativ

e(in

dica

ted

byth

esu

m:+

:)be

twee

nth

et

type

and

am

etav

aria

ble:

1.4.

QU

ALI

TY

CH

AR

AC

TE

RIS

TIC

S11

type

Sche

me

t=

KM

Var

:+:

PF

tty

peM

Var

=In

t

The

r ew

ritin

gfu

nctio

nsno

wop

erat

eon

Sche

me

tin

stea

doft,

guar

ante

eing

that

nom

etav

aria

bles

can

esca

pefr

omth

er e

writ

ing

mec

hani

sm.

Sche

me

tad

dsa

new

case

toth

epa

ttern

func

tor

of

t ,na

mel

ya

cons

tant

case

for

inte

gers

.Th

isal

solif

tsth

ere

stric

tion

that

the

dom

ain

has

toh

ave

som

eso

rtof

var

iabl

eco

nstru

ctor

:ev

ery

type

tfo

rw

hich

we

h av

ea

patte

rnfu

ncto

rca

nno

wbe

exte

nded

toSc

hem

et.

Usa

bilit

y:F

rom

the

p er

spec

tive

of

ap

rogr

amm

erw

hois

addi

nga

new

dom

ain,

cust

omiz

ing

our

dom

ain

r eas

oner

sis

muc

hea

sier

usin

gge

neric

prog

ram

min

g.W

eon

lyne

edto

spec

ifyth

eab

stra

ctsy

ntax

for

the

dom

ain

and

itsse

man

tics-

depe

nden

top

erat

ions

(par

sing

and

pret

ty-p

rintin

g,re

writ

ing

rule

s,as

soci

ativ

ean

dco

mm

utat

ive

oper

ator

s,an

dth

est

rate

gies

).W

ege

tfu

nctio

nalit

ysu

chas

fold

ing,

top-

leve

leq

ualit

y,r e

writ

ing

with

type

-saf

em

etav

aria

ble

exte

nsio

n,tra

vers

als

and

exer

cise

gene

ratio

nfo

rfre

e.W

ithge

neric

prog

ram

min

gw

eal

soge

ta

h ig

her

degr

eeof

com

posa

bilit

y.If

we

have

spec

ified

the

dom

ains

of

ratio

nals

,flo

ats

and

mat

rices

,th

enco

mbi

ning

them

toob

tain

mat

rices

of

r atio

nals

orm

atric

esof

float

s,w

ithth

eco

rrec

tse

tof

rew

rite

rule

s,re

quire

sno

effo

rt.

Effi

cien

cy:

Gen

eric

prog

ram

ste

ndt o

bele

ssef

ficie

ntt h

anth

eir

hand

writ

ten

coun

terp

arts

.C

ompi

lers

dono

tal

way

spe

rfor

mth

ene

cess

ary

optim

izat

ions

to

rem

ove

the

gene

ricr e

pres

enta

tion

t ype

san

dco

nver

sion

func

tions

from

the

com

-pi

led

code

[16]

.W

hile

this

has

b ee

nsh

own

tob e

poss

ible

inat

leas

tth

eap

proa

chof

Alim

arin

ean

dSm

etse

rs[1

],in

the

gene

ral

case

itre

mai

nsan

open

prob

lem

.R

odrig

uez

Yaku

shev

[21]

perfo

rms

asi

mpl

eb

ench

mar

kof

gene

ricpr

ogra

m-

min

glib

rarie

s.Th

etw

oU

nipl

ate

func

tions

test

edar

eap

prox

imat

ely

five

times

slow

erth

anth

eir

hand

writ

ten

coun

terp

arts

.F

orM

ulti

rec,

perfo

rman

ceva

ries

be-

twee

n1.

7an

d47

times

slow

er.

Rew

ritin

gin

Reg

ular

was

benc

hmar

ked

byV

anN

oort

etal

.[1

8],

reve

alin

gth

atit

is,

inge

nera

l,th

ree

tofo

urtim

essl

ower

than

type

-spe

cific

rew

ritin

g.M

ore

r ece

ntly

,M

agalh

˜a e

set

al.

[16]

show

that

stim

ulat

-in

gin

linin

gin

GH

Cca

ndr

amat

ical

lyin

crea

seth

ep

erfo

rman

ceof

Reg

ular

,bu

tno

tof

Mul

tirec

.H

owev

er,

effic

ienc

yis

gene

rally

not

apr

oble

mfo

rou

rdo

mai

nr e

ason

ers.

Sin

ceth

ete

rms

r epr

esen

tex

erci

ses

tobe

wor

ked

with

byhu

man

s,th

eyte

ndto

besm

all.

Hen

ce,

nope

nalty

isno

ticea

ble

for

usin

gan

yof

the

gene

ricve

rsio

ns.

Nev

erth

eles

s,th

isco

uld

pose

apr

oble

mfo

rot

her

larg

eap

plic

atio

ns,

such

asab

-st

ract

synt

axtre

etra

vers

als

onco

mpi

lers

.

Main

tain

abili

ty:

Mai

ntai

ning

the

code

of

the

new

dom

ain

reas

oner

sis

easi

er:

not

only

isth

ere

less

code

tom

aint

ain,

butt

heco

deis

also

mor

ecl

early

stru

ctur

ed.

Initi

ally

,w

ede

velo

ped

ana

ive

gene

ricA

rbitr

ary

gene

rato

rth

atdi

dno

tta

kete

rmsi

zeorc

onst

ruct

orfre

quen

cyin

toac

coun

t.L

ater

we

impr

oved

the

impl

emen

tatio

n

tota

keth

ese

into

acco

unt.

Sin

ceth

ege

nera

tor

isge

neric

,it

ison

lyde

fined

once

,

12C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FO

RD

OM

AIN

RE

AS

ON

ER

S

and

allt

hedo

mai

nsim

med

iate

lybe

nefit

from

the

adva

ntag

es.

W it

hha

ndw

ritte

nin

stan

ces,

we

wou

ldha

veha

dto

goth

roug

hea

chdo

mai

nim

plem

entin

gth

esa

me

impr

ovem

ent

ever

ywhe

re.

Inpa

rticu

lar,

repe

titiv

eco

defra

gmen

tslik

eA

rbitr

ary

and

CoA

rbitr

ary

in-

stan

ces,

fold

s,et

c.le

adto

copy

-and

-pas

tep

rogr

amm

ing,

whi

chca

ngi

ver i

seto

subt

leb

ugs.

By

usin

gge

neric

func

tions

we

can

mov

ea

lot

oft

estin

gto

the

gene

ricpr

ogra

mm

ing

libra

ry(a

sw

ell

asre

duci

ngit)

.W

elo

oked

atth

enu

mbe

rof

line

sofs

ourc

eco

defo

rde

finin

gth

elo

gic

dom

ain,

toge

ther

with

esse

ntia

lfu

nctio

nalit

ysu

chas

top-

leve

leq

ualit

y,ge

nera

tion

of

data

and

rew

ritin

g.Th

isis

asi

mpl

ebu

tre

pres

enta

tive

way

of

com

parin

gth

edo

mai

nre

ason

ers.

The

logi

cdo

mai

nis

not

chos

enbe

caus

eit

isp

artic

ular

lysu

ited

toim

prov

emen

t,bu

tsi

mpl

ybe

caus

eit

ison

eof

our

earli

erdo

mai

ns,

sow

eha

vea

non-

gene

ricdo

mai

nre

ason

erfo

rit.

Our

initi

al,

non-

gene

ricve

rsio

nco

nsis

ted

of

496

lines

of

code

,in

clud

ing

type

-spe

cific

code

for

azi

pper

and

hand

writ

ten

trave

rsal

sov

erth

edo

mai

n.Th

eU

nipl

ate

vers

ion,

whi

chus

edge

neric

trave

rsal

san

dr e

writ

ing,

cons

iste

dof

282

lines

of

code

.U

sing

Mul

tirec

,w

eca

nr e

mov

e

som

eof

the

rem

aini

ngty

pe-s

peci

ficco

defo

rr e

writ

ing,

and

get

thef

old

and

data

gene

ratio

nfu

nctio

nsfo

rfre

e,re

duci

ngth

eto

tall

ine

coun

tto

214,

less

than

50pe

rce

ntof

the

orig

inal

line

coun

t.Th

er e

duct

ion

with

Reg

ular

isth

esa

me,

sinc

eth

ese

libra

ries

have

very

sim

ilar

char

acte

ristic

s.Th

enu

mbe

rof

lines

of

sour

ceco

deis

not

nece

ssar

ilya

repr

esen

tativ

em

etric

,bu

tw

eth

ink

that

inou

rca

seit

faith

fully

expr

esse

sth

eso

urce

code

r edu

ctio

nw

eac

hiev

ed.

Inge

nera

l,a

data

type

with

nco

nstru

ctor

sw

illb e

defin

edin

nlin

esof

code

.U

sing

U n

ipla

te,

we

still

had

tow

rite

the

arbi

trar

y,co

arbi

trar

y,to

ple

vel

equa

lity,

f old

,an

dun

ipla

tefu

nctio

ns.

Eac

hof

thes

eis

gene

rally

defin

edby

patte

rn-m

atch

ing

onth

edo

mai

nda

taty

pe,

ther

efor

eth

eyre

quire

nlin

esea

ch.

Add

ition

ally

,w

eha

dto

defin

eth

eM

etaV

arin

stan

ce.

W it

hM

ultir

ecor

Reg

ular

,ea

chof

the

func

tions

whi

chre

quire

dn

lines

requ

ireon

elin

eon

ly,

and

ther

eis

nolo

nger

aM

etaV

arcl

ass.

We

only

need

toad

dfo

urlin

esof

code

toin

voke

the

Tem

plat

eH

aske

llge

nera

tion

of

gene

ricre

pres

enta

tions

.Tu

rnin

gou

rto

olin

toa

gene

ricpr

ogra

mha

sal

som

ade

the

code

inth

eto

olm

uch

mor

eco

nsis

tent

.W

eha

dto

bepr

ecis

eab

out

our

deci

sion

sin

the

gene

ricco

de,

soth

atal

lge

neric

func

tiona

lity

isco

ncep

tual

lyex

actly

the

sam

efo

rth

edi

ffere

ntdo

mai

ns.

F ur

ther

mor

e,th

ere

isno

wa

sing

leim

plem

enta

tion

for

man

yfu

nctio

nsw

hich

p re

viou

sly

had

one

impl

emen

tatio

npe

rdo

mai

n.Th

eon

lyne

gativ

eim

plic

atio

nin

mai

ntai

nabi

lity

is,p

ossi

bly,

the

incr

ease

dus

eof

adva

nced

Has

kell

p ro

gram

min

gte

chni

ques

inth

eco

de.

The

initi

al

vers

ion

of

the

dom

ain

reas

oner

sw

asw

ritte

nb

yre

lativ

ely

inex

perie

nced

Has

kell

prog

ram

-m

ers.

As

the

num

ber

of

dom

ains

grew

,m

aint

enan

ceof

the

proj

ect

was

hand

edov

erto

anex

perie

nced

Has

kell

prog

ram

mer

,w

hoin

trodu

ced

the

gene

ricve

rsio

nus

ing

U n

ipla

te.

The

vers

ion

u si

ngM

ultir

ecw

ould

prob

ably

not

h av

ebe

enpo

s-si

ble

with

out

clos

eco

ntac

tw

ithth

elib

rary

crea

tors

.Fo

rR

egul

ar,

we

h av

eha

dto

deve

lop

som

efe

atur

esou

rsel

ves

toin

crea

seth

eda

taty

pesu

ppor

tin

the

libra

ry.

We

susp

ect

that

only

ase

ason

edH

aske

llp

rogr

amm

erw

ithb

road

expe

rienc

ein

gene

ricpr

ogra

mm

ing

can

mai

ntai

nou

rcu

rren

tdo

mai

nre

ason

ers.

How

ever

,bi

g-

1.5.

CO

NC

LUS

ION

S13

ger

prog

ram

sna

tura

llyb

ecom

em

ore

com

plex

,an

dou

rdo

mai

nr e

ason

ers

now

offe

rm

uch

mor

efu

nctio

nalit

yth

anin

the

initi

al

vers

ion.

Nev

erth

eles

s,ca

reha

sto

beta

ken

toav

oid

prol

ifera

tion

of

gene

rics-

rela

ted

code

thro

ugho

utth

een

tire

code

b as

e.M

ultir

ec,

for

inst

ance

,in

trodu

ces

the

con-

cept

sof

‘fam

ilyty

pe’

and

‘ind

exty

pe.’

Inm

ost

othe

rge

neric

p ro

gram

min

gli-

brar

ies,

ther

eis

asi

ngle

gene

ricty

pe,

like

the

ain

Uni

plat

ea.

InM

ulti

rec,

we

have

Fam

ϕix

,with

ϕre

pres

entin

gth

efa

mily

and

ixa

parti

cula

rin

dex

onth

isfa

mily

.Th

isca

uses

prop

agat

ion

of

para

met

ers

inty

pecl

asse

s,an

din

crea

ses

the

over

all

com

plex

ityof

the

code

inth

edo

mai

nre

ason

ers.

For

inst

ance

,in

stea

dof

anex

er-

cise

onex

pres

sion

s(E

xerc

ise

Exp

r),

with

Mul

tirec

we

have

anex

erci

seon

the

ex-

pres

sion

type

inth

efa

mily

of

data

type

sfo

rex

pres

sion

s(E

xerc

ise

Exp

rFam

Exp

r).

How

ever

,fo

rm

any

dom

ains

the

fam

ilyofd

atat

ypes

cont

ains

asi

ngle

type

.Th

ere

isno

addi

tiona

lge

nera

lity,

but

the

fam

ilyty

peha

sto

b epr

opag

ated

thro

ugh

the

entir

eco

de.

This

redu

ces

the

over

all

r ead

abili

tyan

dm

aint

aina

bilit

yof

the

code

.

Por

tabi

lity:

The

orig

inal

dom

ain

r eas

oner

sw

ere

deve

lope

din

Has

kell

98[2

0],

whi

chm

ade

thei

rpo

rtab

ility

good

.W

hen

we

mov

edto

gene

ricdo

mai

nre

ason

-

ers

we

first

u se

dan

embe

dded

impl

emen

tatio

nof

Uni

plat

e.Th

isim

plem

enta

tion

was

asu

bset

of

the

Uni

plat

epa

ckag

eav

aila

ble

onH

acka

geD

B,

whi

chw

asen

-tir

ely

Has

kell

98,

soit

did

not

influ

ence

port

abili

ty.

Then

we

used

Mul

tirec

and

Reg

ular

,w

hich

intro

duce

depe

nden

cies

ona

num

ber

of

adva

nced

exte

nsio

nsof

Has

kell

(suc

has

type

fam

ilies

)on

lyav

aila

ble

inG

HC

,th

em

ain

com

pile

rfo

rH

aske

ll.Th

ese

exte

nsio

nsar

elia

ble

toch

ange

whe

nne

wve

rsio

nsoft

heco

mpi

ler

are

r ele

ased

,w

hich

mea

nsw

em

ight

have

toad

apt

our

code

.A

sa

cons

eque

nce,

port

abili

tyis

wor

se.

1.5

CO

NC

LUS

ION

S

The

use

of

gene

ricp

rogr

amm

ing

libra

ries

inou

rdo

mai

nre

ason

ers

has

give

nu s

incr

ease

dfu

nctio

nalit

y,re

liabi

lity,

usab

ility

and

mai

ntai

nabi

lity.

This

isdu

eto

acl

eare

rse

para

tion

of

conc

erns

,a

decr

ease

dnu

mbe

rof

lines

of

code

,hi

gher

com

-po

sabi

lity

and

mak

ing

itsi

mpl

erto

add

ane

wdo

mai

n.U

sing

gene

ricpr

ogra

m-

min

gpo

ssib

lyle

ads

tow

orse

perfo

rman

ce,

but

this

isno

tno

ticea

ble

for

user

s.U

sing

Mul

tirec

and

Reg

ular

we

depe

ndon

mor

ela

ngua

geex

tens

ions

and

can

only

com

pile

with

GH

C.

We

have

also

seen

that

usin

ga

sim

ple

gene

ricp

rogr

amm

ing

libra

ry(U

nipl

ate)

give

su s

aco

nsid

erab

leim

prov

emen

tin

our

code

qual

ity,

but

itev

entu

ally

be-

com

esa

limita

tion

inits

elf.

The

r ew

ritin

gm

echa

nism

,fo

rin

stan

ce,

requ

ired

the

dom

ains

toha

veva

riabl

es,

and

we

coul

dno

tw

rite

gene

ricp

rodu

cers

.M

ovi

ngto

mor

eco

mpl

exge

neric

prog

ram

min

glib

rarie

slif

ted

thes

ere

stric

tions

,bu

tm

ade

usgi

veu

pon

com

pile

rp

orta

bilit

y.W

ebe

lieve

that

the

use

of

gene

ricp

rogr

amm

ing

and

p ar

ticul

arly

of

Reg

ular

will

also

enab

leu s

toim

prov

eth

eea

seof

use

and

func

tiona

lity

of

the

dom

ain

reas

oner

sfu

rther

.W

ear

ecu

rren

tlylo

okin

gin

tore

writ

ing

expr

essi

ons

taki

ngin

to

14C

HA

PTE

R1.

GE

NE

RIC

PR

OG

RA

MM

ING

FO

RD

OM

AIN

RE

AS

ON

ER

S

acco

unt

the

asso

ciat

ivity

and

com

mut

ativ

ityof

(som

e)b

inar

yop

erat

ors.

This

isus

eful

for

two

reas

ons:

itre

duce

sth

enu

mbe

rof

rule

soft

hedo

mai

n4an

dit

sim

pli-

fies

reco

gniz

ing

the

appl

icat

ion

of ru

les

toa

term

b y

the

user

.S

ince

p re

tty-p

rinte

dex

pres

sion

sal

mos

tne

ver

cont

ain

unne

cess

ary

pare

nthe

ses,

au s

eris

gene

rally

un-

awar

eof

asso

ciat

ivity

.Fo

rin

crea

sed

r elia

bilit

yin

the

trave

rsal

s,w

ew

ant

tous

eth

ege

neric

zipp

er[1

2].

Ther

eis

anim

plem

enta

tion

of

azi

pper

for

Mul

tirec

u si

ngty

pe-in

dexe

dda

taty

pes

thro

ugh

type

fam

ilies

.Th

isim

plem

enta

tion

can

easi

lybe

conv

erte

dto

Reg

ular

.Th

isw

ould

repl

ace

the

curr

ent

unty

ped

appr

oach

usin

ga

list

of

inte

gers

tore

pres

ent

alo

catio

nin

ada

taty

pe.

We

also

p la

nto

look

into

the

gene

ricse

lect

ion

prob

lem

inth

eex

erci

seas

sist

ant:

the

user

shou

ldb e

able

tose

lect

asu

bexp

ress

ion

and

appl

ya

r ule

toth

atpa

rtof

the

expr

essi

on.

Apa

rtfr

omso

me

dom

ain-

spec

ific

info

rmat

ion

r ega

rdin

gth

ew

ayte

rms

are

p re

tty-p

rinte

dan

dw

hich

term

sar

ese

lect

able

,th

ispr

oble

mca

nal

sob e

solv

edw

itha

gene

rical

go-

rithm

.Th

eus

eof

gene

ricpr

ogra

mm

ing

tech

niqu

esin

our

dom

ain

reas

oner

spr

ovid

esus

with

ap

iece

of

softw

are

of

b et

ter

over

all

qual

ity.

The

adva

ntag

escl

early

out-

wei

ghth

edi

sadv

anta

ges,

and

the

effo

rtin

vest

edin

totra

nsla

ting

toa

gene

ricap

-

proa

chpa

yo

ffw

hen

addi

ngm

ultip

lene

wdo

mai

ns.

W e

expe

ctot

her

proj

ects

po-

tent

ially

tobe

nefit

from

the

appl

icat

ion

of

gene

ricpr

ogra

mm

ing

tech

niqu

esto

o.H

owev

er,

not

all

proj

ects

are

suita

ble

for

this

.In

our

case

,w

eha

vese

vera

ldo

-m

ains

whi

chre

quire

sim

ilar

func

tiona

lity.

Eac

hdo

mai

nis

repr

esen

ted

b y

one

orm

ore

data

type

s,on

top

of

whi

chth

efu

nctio

nalit

yis

impl

emen

ted.

Oth

erpr

ojec

tsw

hich

man

ipul

ate

seve

ral

data

type

s(e

.g.

stru

ctur

eed

itors

),or

perh

aps

asi

ngle

,la

rge

data

type

(e.g

.co

mpi

lers

),ar

eal

sow

ell-s

uite

dfo

rth

eap

plic

atio

nof

gene

ricpr

ogra

mm

ing

and

shou

ldbe

nefit

inth

esa

me

way

asou

rdo

mai

nre

ason

ers

did.

Ack

now

ledg

emen

ts:

This

wor

kha

sb

een

parti

ally

fund

edb

yth

ePo

rtugu

ese

Foun

datio

nfo

rSc

ienc

ean

dTe

chno

logy

(FC

T),

via

the

SF

RH

/BD

/359

99/2

007

gran

t,an

dby

the

Net

herla

nds

Org

aniz

atio

nfo

rS

cien

tific

Res

earc

h(N

WO

),th

roug

hits

proj

ect

on‘R

eal-l

ifeD

atat

ype-

Gen

eric

Pro

gram

min

g’(6

12.0

63.6

13).

W e

than

kA

ndre

sL¨o

hfo

rhi

she

lpw

ithus

ing

Mul

tirec

and

Erik

Hes

selin

kfo

rhi

sw

ork

onits

exte

nsio

n.A

lex

Ger

des

prov

ided

feed

back

onan

early

vers

ion

oft

his

pape

r.H

ar-

riePa

ssie

ran

dA

rthu

rva

nLe

euw

enco

ntrib

uted

tool

der

vers

ions

of

the

exer

cise

assi

stan

ts.

We

also

than

kth

ean

onym

ous

refe

rees

for

thei

rhe

lpfu

lfe

edba

ck.

RE

FE

RE

NC

ES

[1]

A.

Alim

arin

ean

dS

.S

met

sers

.O

ptim

izin

gge

neric

func

tions

.In

D.

Koz

enan

dC

.S

hank

land

,ed

itors

,M

PC

,vo

lum

e3

125

of

Lect

ure

N o

tes

inC

ompu

ter

Sci

ence

,pa

ges

16–3

1.S

prin

ger,

2004

.

[2]

R.

Bac

khou

se,

P.Ja

nsso

n,J.

Jeur

ing,

and

L .

Mee

rtens

.G

ener

icpr

ogra

mm

ing—

anin

trod

uctio

n.In

AFP’

98,

volu

me

1608

of

L N

CS,

page

s28

–115

.S

prin

ger,

1999

.

4Spe

cifying

x+

0x

shou

ldb

een

ough

toex

pres

sth

ene

utra

lel

emen

tof

addi

tion.

The

extra

r ule

0+

xx

shou

ldno

tb

ene

cess

ary.

1.5.

CO

NC

LU

SIO

NS

15

[3]

P.B

oon

and

P.D

rijve

rs.

Alg

ebra

enap

plet

s,le

ren

enon

derw

ijzen

(alg

ebra

and

appl

ets,

lear

ning

and

teac

hing

,in

Dut

ch).

http

://w

ww

.fi.u

u.n

l/p

ub

lica

tie

s/lite

ratu

ur/

65

71.p

df,

2005

.

[4]

K.

Cla

esse

nan

dJ .

Hug

hes.

Qui

ckC

heck

:a

light

wei

ght

t ool

for

rand

omte

stin

go

fH

aske

llpr

ogra

ms.

InP

roce

edin

gsoft

he5t

hA

CM

SIG

PLA

NI n

tern

atio

nal

Con

fer-

ence

onF

unct

iona

lP

rogr

amm

ing,

I CFP

2 00

0,p

ages

268–

279.

AC

M,

2000

.

[5]

A.

Coh

en,

H.

Cuy

pers

,E

.Rei

nald

oB

arre

iro,

and

H.

Ste

rk.

Inte

ract

ive

mat

hem

atic

aldo

cum

ents

onth

ew

eb.

InA

lgeb

ra,

Geo

met

ryan

dS

oftw

are

Syst

ems,

p ag

es28

9–30

6.S

prin

ger,

2003

.

[6]

A.G

erde

s,B

.Hee

ren,

J.Je

urin

g,an

dS

.Stu

urm

an.

Feed

back

serv

ices

for

exer

cise

as-

sist

ants

.In

E C

EL20

07:

P ro

ceed

ings

of th

e7t

hE

urop

ean

Con

fere

nce

one-

Lear

ning

,20

08.

A ls

oav

aila

ble

asTe

chni

cal

repo

rtU

trech

tU

nive

rsity

UU

-CS

-200

8-01

8.

[7]

G.G

ogua

dze,

A .G

onz

a´le

zP

alom

o,an

dE

.Mel

is.

Inte

ract

ivity

of e

xerc

ises

inA

ctiv

e-M

ath.

InI n

tern

atio

nal

Con

fere

nce

onC

ompu

ters

inE

duca

tion,

I CC

E2

005,

2005

.

[8]

B.

Hee

ren

and

J.Je

urin

g.R

ecog

nizi

ngst

rate

gies

.In

A.

Mid

deld

orp,

edito

r,W

RS

2008

:R

edu

ctio

nSt

rate

gies

inR

ew

ritin

gan

dP

rogr

amm

ing,

8th

Inte

rnat

iona

lW

ork-

shop

,20

08.

[9]

B.

Hee

ren,

J .Je

urin

g,A

.va

nLe

euw

en,

and

A.

Ger

des.

Spe

cify

ing

stra

tegi

esfo

rex

erci

ses.

InS

.Aut

exie

ret

al.,

edito

r,M

KM

2008

:M

ath

emat

ical

K no

wle

dge

M a

n-ag

emen

t,vo

lum

e51

44o

fL N

AI,

p ag

es43

0–44

5.S

prin

ger,

2008

.

[10]

E.

Hes

selin

k.G

ener

icp

rogr

amm

ing

with

fixed

p oi

nts

for

para

met

rized

data

type

s.M

aste

r’s

thes

is,

Utre

cht

Uni

vers

ity,

2009

.

[11]

R.H

inze

,J.

Jeur

ing,

and

A.

L o¨h.

Com

parin

gap

proc

hes

toge

neric

p ro

gram

min

gin

Has

kell.

InD

atat

ype-

Gen

eric

Pro

gram

min

g,LN

CS

4 71

9,p

ages

72–1

49.

Spr

inge

r,20

07.

[12]

G.H

uet.

The

zipp

er.

J FP

,7(

5):5

49–5

54,

1997

.

[13]

ISO

/IEC

.91

26-1

:200

1:

Sof

twar

een

gine

erin

g—pr

oduc

tqu

ality

—pa

rt1:

Qua

lity

mod

el.

Tech

nica

lre

port,

Inte

rnat

iona

lO

rgan

izat

ion

for

Sta

ndar

diza

tion,

Gen

eva,

Sw

itzer

land

,20

01.

[14]

R.

L ¨a

mm

elan

dS

.P

eyto

nJo

nes.

Scra

pyo

urbo

ilerp

late

:a

prac

tical

appr

oach

to

gene

ricp

rogr

amm

ing.

InT

LD

I’0

3,p

ages

26–3

7,20

03.

[15]

J.Lo

dder

,H

.Pa

ssie

r,an

dS

.S

tuur

man

.U

sing

IDE

AS

inte

achi

nglo

gic,

less

ons

lear

ned.

InC

SS

E20

08:

I nte

rnat

iona

lC

onfe

renc

eon

Com

pute

rSc

ienc

ean

dS

oftw

are

Eng

inee

ring,

page

s55

3–55

6,20

08.

[16]

J.P .

M ag

alha ˜

es,

S.H

olde

rman

s,J .

Jeur

ing,

and

A.L

o¨h.

Opt

imiz

ing

gene

rics

isea

sy!

Tech

nica

lR

epor

tU

U-C

S-2

009-

022,

Dep

artm

ent

ofI

nfor

mat

ion

and

Com

putin

gS

ci-

ence

s,U

trech

tU

nive

rsity

,20

09.

[17]

N.M

itche

llan

dC

.Run

cim

an.

Uni

form

boile

rpla

tean

dlis

tpr

oces

sing

.In

H a

skel

l’07

,20

07.

[18]

T.

van

Noo

rt,

A.

Rod

rigue

zY

akus

hev,

S.H

old

erm

ans,

J .Je

urin

g,an

dB

.H

eere

n.A

light

wei

ght

appr

oach

toda

taty

pe-g

ener

icr e

writ

ing.

InW

GP

’08,

page

s13

–24.

AC

M,

2008

.

[19]

H.

Pass

ier

and

J.Je

urin

g.Fe

edba

cki n

anin

tera

ctiv

eeq

uatio

nso

lver

.In

M.

Sepp

a¨la

¨,S

.Xam

bo,

and

O.C

apro

tti,

edito

rs,

Web

ALT

200

6:P

roce

edin

gsof

the

Web

Adv

ance

dLe

arni

ngC

onfe

renc

ean

dE

xhi

bitio

n,p

ages

53–6

8.O

yW

ebA

LTIn

c.,

2006

.

16C

HA

PT

ER

1.G

EN

ER

ICP

RO

GR

AM

MIN

GF

OR

DO

MA

IN R

EA

SO

NE

RS

[20]

S.

Pey

ton

Jone

set

al.

Has

kell

98,

Lang

uage

and

L ib

rarie

s.Th

eR

evis

edR

epor

t.C

ambr

idge

Uni

vers

ityPr

ess,

2003

.A

spec

ial

issu

eo

fJ F

P.

[21]

A.

Rod

rigue

zY

akus

hev.

Tow

ards

Get

ting

Gen

eric

P ro

gram

min

gR

ead

yfo

rP

rime

Tim

e.P

hDth

esis

,U

trech

tU

nive

rsity

,20

09.

[22]

A.

Rod

rigue

zY

akus

hev,

S.

Hol

derm

ans,

A.

L o¨h

,an

dJ .

Jeur

ing.

Gen

eric

prog

ram

-m

ing

with

fixed

poin

tsfo

rm

utua

llyr e

curs

ive

data

type

s.In

Pro

ceed

ings

of th

eA

CM

SIG

PLA

NI n

tern

atio

nal

Con

fere

nce

onF

unct

iona

lP

rogr

amm

ing,

I CFP

2009

,20

09.

[23]

A.

Rod

rigue

zY

akus

hev,

J.Je

urin

g,P.

Jans

son,

A.

Ger

des,

O.

Kis

elyo

v,an

dB

.C

.d.

S.

Oliv

eira

.C

ompa

ring

libra

ries

for

gene

ricp

rogr

amm

ing

inH

aske

ll.In

Has

kell

’08,

p ag

es111

–122

,20

08.

[24]

N.

Win

stan

ley

and

J.M

each

am.

DrI

FT

Use

rG

uide

.http

://re

pe

tae

.ne

t/

co

mp

ute

r/h

ask

ell

/Dr

IFT

/d

rift

.htm

l,Fe

brua

ry20

08.