1

Im new to learning Haskell and have been using the book "Haskell-The Craft of Functional Programming 3rd edition" and am stuck on Chapter 12 regarding regular expressions, problem 12.16 in particular:

implement the following functions: option,plus:: RegExp->RegExp -where option e matches 0 or 1 occurence of e and plus e matches 1 or more occurence of e.

Im not sure where to evenbegin so any help would be appreciated! Thanks

2
  • Check this resource Commented Feb 22, 2016 at 22:59
  • 1
    I don't know that this will help with the particular exercise, but regex-applicative offers a particularly pleasant API for dealing with regular languages. Commented Feb 22, 2016 at 23:38

1 Answer 1

1

According to the star function, plus function should be like this:

plus :: RegExp -> RegExp plus e = e <*> star e 

Where a <*> b means "a followed by b", and star matches 0 or multiple occurences.

Try to use epsilon and (|||) for option function.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.