Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Метод указ практика перевода Кудряшова.doc
Скачиваний:
1
Добавлен:
01.04.2025
Размер:
326 Кб
Скачать
☆

Модуль 5 Научный текст Перевод сокращений

Задание 1: Выполните предпереводческий анализ следующего текста. Переведите текст и произведите анализ примененных трансформаций.

Monads for functional programming

Philip Wadler, University of Glasgow

Department of Computing Science, University of Glasgow, G12 8QQ, Scotland

(wadler@dcs.glasgow.ac.uk)

Abstract. The use of monads to structure functional programs is described. Monads provide a convenient framework for simulating effects found in other languages, such as global state, exception handling, output, or non-determinism. Three case studies are looked at in detail: how monads ease the modification of a simple evaluator; how monads act as the basis of a datatype of arrays subject to in-place update; and how monads can be used to build parsers.

1 Introduction

Shall I be pure or impure?

The functional programming community divides into two camps. Pure languages, such as Miranda and Haskell, are lambda calculus pure and simple. Impure languages, such as Scheme and Standard ML, augment lambda calculus with a number of possible effects, such as assignment, exceptions, or continuations. Pure languages are easier to reason about and may benefit from lazy evaluation, while impure languages offer efficiency benefits and sometimes make possible a more compact mode of expression.

Recent advances in theoretical computing science, notably in the areas of type theory and category theory, have suggested new approaches that may integrate the benefits of the pure and impure schools. These notes describe one, the use of monads to integrate impure effects into pure functional languages.

The concept of a monad, which arises from category theory, has been applied by Moggi to structure the denotational semantics of programming languages. The same technique can be applied to structure functional programs.

The applications of monads will be illustrated with three case studies. Section 2 introduces monads by showing how they can be used to structure a simple evaluator so that it is easy to modify. Section 3 describes the laws satisfied by monads. Section 4 shows how monads provide a new solution to the old problem of providing updatable state in pure functional languages. Section 5 applies monads to the problem of building recursive descent parsers; this is of interest in its own right, and because it provides a paradigm for sequencing and alternation, two of the central concepts of computing.

It is doubtful that the structuring methods presented here would have been discovered without the insight afforded by category theory. But once discovered they are easily expressed without any reference to things categorical. No knowledge of category theory is required to read these notes.

The examples will be given in Haskell, but no knowledge of that is required either. What is required is a passing familiarity with the basics of pure and impure functional programming. The languages referred to are Haskell, Miranda, Standard ML, and Scheme.

2 Evaluating monads

Pure functional languages have this advantage: all flow of data is made explicit. And this disadvantage: sometimes it is painfully explicit.

A program in a pure functional language is written as a set of equations. Explicit data flow ensures that the value of an expression depends only on its free variables. Hence substitution of equals for equals is always valid, making such programs especially easy to reason about. Explicit data flow also ensures that the order of computation is irrelevant, making such programs susceptible to lazy evaluation.

It is with regard to modularity that explicit data flow becomes both a blessing and a curse. On the one hand, it is the ultimate in modularity. All data in and all data out are rendered manifest and accessible, providing a maximum of flexibility. On the other hand, it is the nadir of modularity. The essence of an algorithm can become buried under the plumbing required to carry data from its point of creation to its point of use.

Say I write an evaluator in a pure functional language.

- To add an error handling to it, I need to modify each recursive call to check for and handle errors appropriately. Had I used an impure language with exceptions, no such restructuring would be needed.

- To add a count of operations performed to it, I need to modify each recursive call to pass around such counts appropriately. Had I used an impure language with a global variable that could be incremented, no such restructuring would be needed…

З адание 2: Подберите соответствия для следующих сокращений. Проанализируйте, по каким правилам может осуществляться перевод сокращений.

1) USSR 2) USA 3) EC 4) EU 5) EEC

6) CIS 7) UK 8) GB 9) FBI 10) CIA

11) CID 12) UN 13) TASS 14) BBC 15) KGB

16) NASA 17) NATO 18) NHS 19) PR 20) ELT

21) SEPA 22) CPSU 23) SAS 24) GI 25) RAF

26) RN 27) MOT 28) PM 29) MP 30) BW

31) PC 32) WPC 33) LAPD 34) NYPD 35) JP

36) VIP 37) ITV 38) POW 39) OAP 40) BST

41) EMS 42) a/c 43) VAT 44) GDP 45) BSc

46) BA 47) Ph.D. 48) GCSE 49) MA 50) MD

51) MSc 52) SOS 53) DNA 54) HIV 55) MS

56) VD 57) GP 58) AIDS 59) DC 60) AC

61) PVC 62) PS 63) PO 64) p. 65) i.e.

66) a.o.b. 67) a.s.a.p. 68) PTO 69) NB 70) s.a.e.

71) RSVP 72) ibid 73) F 74) C 75) ID

74) Bros 75) UFO 76) AWOL 77) CD 80) PC

81) VDU 82) CD-ROM 83) RAM 84) L-plate 85) RV

86) No 87) B.Y.O.B. 88) a.m. 89) p.m. 90) PE

91) B&B 92) blvd 93) Rd. 94) Av, Ave 95) RE

96) RIP 97) St 98) RC 99) PA 100) IQ

101) OPEC 102) ISO 103) BP 104) MBA 105) m

106) mph 107) mpg 108) k 109) g 110) mg

111) kg 112) l 113) oz 114) рt 115) lb

Задание 3: Дайте определение контекстуального сокращения. Подберите эквиваленты для следующих контекстуальных сокращений.

1. US DV (Diversity Immigrant Visa) program

2. UBD (underbalanced drilling)

3. ALARA (as low as reasonably achievable) principle

4. wRLS (weighted recursive least-squares) method

5. TS (Takagi-Sugeno) fuzzy models

6. VES (viscoelastic surfactant) fracturing liquid