Haskell代写:COMP3141 Assignment代写,可接急单

Haskell 是一种纯粹的函数式编程语言,是一种现代的、标准的、纯函数式编程和非严格的语言。它专为处理从数字到符号的广泛应用而设计。它具有富有表现力的语法和非常丰富的内置架构。

Haskell 作为一种编程语言可以做什么?

开发和维护大型软件项目需要大量的工作、时间和金钱。Haskell 等函数式编程语言可以提供缓解。由于以下优点,Haskell 是一个特别有吸引力的选择:

  • 可以显着提高开发人员的生产力。
  • Haskell 软件的代码简短、清晰且易于维护。
  • Haskell 应用程序不易出错并提供高可靠性。
  • 程序员和语言之间的“语义”差距很小。

因此,Haskell 适合作为广泛应用的编程语言。函数式语言特别适用于应该提供高度可修改性和易于维护的程序。Haskell 的优势在开发可以实际执行的规范和原型方面也发挥了作用,因此可以进行测试和调试。


  • 易于理解:函数式程序更容易理解。没有命令性或程序性。函数式程序通常很容易理解,但它们的实现却很困难。
  • 代码重用:Haskell 支持多态。比如上面的代码不仅支持整数,还支持浮点数、字符列表、列表列表等
  • 内存管理:在c这样的语言中,内存管理是通过关键字malloc或calloc来完成的,程序员在使用后需要释放内存。但是在像 Haskell 这样的函数式编程中,程序员可以从这个负担中解脱出来。存储由垃圾收集器自动分配、隐式初始化和恢复。
  • 静态类型:静态类型语言是一种在编译时已知变量类型的语言。它帮助程序员在编译时识别错误。它有助于降低大型程序的复杂性。
  • 纯函数式:它是一种构建程序的风格,将所有计算视为数学函数。
  • 惰性求值:像 Haskell 这样的函数式编程跳过了函数中参数的求值。这提高了代码的性能,帮助程序编写得非常好。
  • 类型推断:类型推断解决了显式写入每种程序类型的代码冗余。
  • 多线程:线程是程序中的虚拟处理器处理/处理步骤。具有单线程的语言意味着一次只执行一次。Haskell 是一种多线程语言,使其能够在程序中并行执行语句。多线程增加了编程语言执行的处理能力。

Haskell代写案例:Haskell-Augmented Regular Expressions COMP3141

Provided Code

The provided code consists of a number of modules:

Hare.hs contains the stubs of the code you should implement.

Untyped.hs contains an untyped, unextended version of the regex engine. HareMonad.hs contains the monadic type used to write the matching algorithm. Tests.hs contains the main function for running tests.

Tests/Support.hs contains the support code for running tests.

Tests/UnitTests.hs contains properties for the basic regular expressions. Tests/Transcript.hs contains some acceptance tests for your combinators, for analysing a UNSW transcript.

Tests/Examples.hs contains all examples from this spec, as unit tests.

Regular Expressions

Regular expressions are a popular way to describe and manipulate patterns of strings. Often they are used to search for a substring that matches a particular pattern, and then extracting information from that substring. Many languages include regular expressions as a built in feature or in their standard library. If you have done COMP2041, you will have been exposed to several such languages. Unfortunately, Haskell is not such a language. To remedy this, Helen the Hare started to design H.A.R.E, a regular expressions library for Haskell. She started by encoding the basic building blocks of regular expressions as a Haskell data type.

data RE = Empty — Matches the empty string

| Fail — Matches no strings

| Char [Char] — Matches a single character from the list

| Seq RE RE — Matches the two expressions in sequence

| Choose RE RE — Matches either the first, or the second

| Star RE — Matches the expression zero or more times

In order to define a matching algorithm for regular expressions, Helen defined a type called Hare (found in HareMonad.hs), which is similar to State String except that the return type is wrapped in a monad f:

newtype Hare f a = Hare { runHare :: String -> f (String, a) }

The hare function can be used to “run” a Hare computation on a string:

hare :: Functor f => Hare f a -> String -> f a

hare a s = fmap snd (runHare a s)

Helen has parameterised the Hare type by f so that it could be instantiated to Maybe if the user only wishes to find the first match for a particular regular expression, or to the list type constructor [] if the user wishes to find all possible matches of the regular expression. This requires us to make use of the Alternative type class, which has two built in methods:

class Applicative f => Alternative f where

empty :: f a

(<|>) :: f a -> f a -> f a

The empty method denotes failure. For the list instance, it is the empty list [], whereas for the Maybe instance it is Nothing. The () method denotes alternation. For the list instance it is the same as concatentation (++), whereas for the Maybe instance, it is a left-biased choice, like so:

instance Alternative Maybe where

empty = Nothing

Just a <|> b = Just a

Nothing <|> b = b

To avoid confusing empty with the Empty constructor for regular expressions, Helen also defined an alias for empty, called failure:

failure :: (Alternative f, Monad f) => Hare f a failure = empty


Assignment Exmaple

Recent Case

Service Scope

oop|Processing|JS|Ruby|Scala|Rust|Data Mining|数据库|Oracle|Mysql|Sqlite|IOS|Data Mining|网络编程|多线程编程|Linux编程操作系统|计算机网络|留学生|编程|程序|代写|加急|个人代写|作业代写|Assignment