Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete exercises 1-9 in Part A (page 5) and 1 of the exercises in Part B using the Haskell language. Building Exam DSL Suppose Professor

Complete exercises 1-9 in Part A (page 5) and 1 of the exercises in Part B using the Haskell language. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Building Exam DSL Suppose Professor Harold Pedantic decides to create a DSL to encode his (allegedly vicious) multiple choice examinations. Since his course uses Haskell to teach programming language organization, he wishes to implement the language processor in Haskell. Professor Pedantic is too busy to do the task himself. He is also cheap, so he assigns us, the students in his class, the task of developing a prototype. In the initial prototype, we do not concern ourselves with the concrete syntax of the Exam DSI. We focus on design of the AST as a Haskell algebraic data type. We seek to design a few useful functions to manipulate the AST and output an exam as HTML First, let's focus on multiple-choice questions. For this prototype, we can assume a question has the following components: the text of the question .a group of several choices for the answer to the question, exactly one of which should be be a correct answer to the question . a group of tags identifying topics covered by the question We can state a question using the Haskell data type Question, which has a single constructor Ask. It has three components a list of applicable topic tags, the text of the question, and a list of possible answers to the question. type QTextString type Tag data Question Ask [Tag] QText [Choice] deriving Shou String We use the type QText to describe the text of a question. We also use the type Tag to describe the topic tags we can associate with a question. We can then state a possible answer to the question using the data type Choice, which has a single constructor Answer. It has two components the text of the answer and a Boolean value that indicates whether this is a correct answer to the question .e. True) or not. type AText = String data Choice Ansver AText Bool deriving (Eq, Shou) As above, we use the type AText to describe the text of an answer. For example, we could encode the question "Which of the following is a required course?" as follows. Ask "curriculum" "Which of the folloving is a required course? Answer "CSci 323" False, 2 Building Exam DSL Suppose Professor Harold Pedantic decides to create a DSL to encode his (allegedly vicious) multiple choice examinations. Since his course uses Haskell to teach programming language organization, he wishes to implement the language processor in Haskell. Professor Pedantic is too busy to do the task himself. He is also cheap, so he assigns us, the students in his class, the task of developing a prototype. In the initial prototype, we do not concern ourselves with the concrete syntax of the Exam DSI. We focus on design of the AST as a Haskell algebraic data type. We seek to design a few useful functions to manipulate the AST and output an exam as HTML First, let's focus on multiple-choice questions. For this prototype, we can assume a question has the following components: the text of the question .a group of several choices for the answer to the question, exactly one of which should be be a correct answer to the question . a group of tags identifying topics covered by the question We can state a question using the Haskell data type Question, which has a single constructor Ask. It has three components a list of applicable topic tags, the text of the question, and a list of possible answers to the question. type QTextString type Tag data Question Ask [Tag] QText [Choice] deriving Shou String We use the type QText to describe the text of a question. We also use the type Tag to describe the topic tags we can associate with a question. We can then state a possible answer to the question using the data type Choice, which has a single constructor Answer. It has two components the text of the answer and a Boolean value that indicates whether this is a correct answer to the question .e. True) or not. type AText = String data Choice Ansver AText Bool deriving (Eq, Shou) As above, we use the type AText to describe the text of an answer. For example, we could encode the question "Which of the following is a required course?" as follows. Ask "curriculum" "Which of the folloving is a required course? Answer "CSci 323" False, 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Public Finance

Authors: Harvey S. Rosen

5th Edition

025617329X, 978-0256173291

Students also viewed these Databases questions