• Keine Ergebnisse gefunden

Simple haskell -Programs

N/A
N/A
Protected

Academic year: 2021

Aktie "Simple haskell -Programs"

Copied!
4
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Domain of a haskell-program

Least solution of

Dom = Functions ⊕ Tuples ⊕ Constructions0 ⊕ Constructions1 ⊕ . . . where Functions = hDom → Domi

Tuples = {⊥, ( )} ⊕ (Dom × Dom) ⊕ (Dom × Dom × Dom) ⊕ . . . Constructionsn = (Conn × Domn)

Environment

ρ : Var → Dom with ρ = {var1, . . . , varn / d1, . . . , dn} (ρ1 + ρ2)(var) =

ρ2(var), if ρ2(var) is defined ρ1(var), otherwise.

Initial environment ω

for all pre-defined variables in haskell

37

(2)

Simple haskell -Programs

• no type synonyms, no type classes, no pre-defined lists

• only one declaration of the form var = exp exp → var

| constr

| integer

| float

| char

| (exp

1, . . . , exp

n), n ≥ 0

| (exp

1 exp

2)

| if exp

1 then exp

2 else exp

3

| let var = exp in exp

| \ var → exp

38

(3)

Semantics of haskell -Programs

Val [[var]] ρ = ρ(var)

Val [[constr0]] ρ = constr0 in Constructions0 in Dom

Val [[constrn]] ρ = f in Functions in Dom, where f d1 d2 . . . dn = (constrn, d1, . . . , dn) inConstructionsn inDom

Val [[(exp1, ..., exp

n)]] ρ = ( Val [[exp1]] ρ, . . . , Val [[exp

n]] ρ ) in Tuplesn in Dom,

where n = 0 or n ≥ 2 Val [[(exp)]] ρ = Val [[exp]] ρ

Val [[(exp1 exp2)]] ρ = f( Val [[exp2]] ρ ),

where Val [[exp1]] ρ = f in Functions in Dom

39

(4)

Val hh if exp1 then exp2 else exp

3

ii

ρ =













Val [[exp2]] ρ, if Val [[exp1]] ρ = True

in Constructions0 in Dom

Val [[exp

3]] ρ, in Val [[exp

1]] ρ = False

in Constructions0 in Dom

⊥, otherwise

Val

let var = exp in exp

ρ = Val [[exp]] (ρ + {var /lfp f}),

where f : Dom → Dom and f(d) = Val [[exp]] (ρ + {var/d})

Val [[\var -> exp]] ρ = f in Functions in Dom

where f(d) = Val [[exp]] (ρ + {var / d})

40

Referenzen

ÄHNLICHE DOKUMENTE

We exhibit a dual of a stochastic program with simple recourse -- with random parameters in the technoloty matrix and the right-hand sides,and with quadratic recourse costs --

In software development, a domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, a particular

Imprecise Error Semantics [Peyton Jones et al... Imprecise Error Semantics [Peyton Jones

Imprecise Error Semantics [Peyton Jones et al... Imprecise Error Semantics [Peyton Jones

[r]

exp tr results from exp by repeated application of Rules (1) – (12) and no rule is applicable to exp tr any more.

[r]

[r]