Haskell – Introduction


Haskell is a programming language function (functional programming) and lazy (lazy):))) (we’ll find out later) was created in 1980 by a panel of academics. There were also a number of functional programming languages ​​in those days, but everyone had a different idea. So they eventually got together and built a new programming language with the best of functional programming language features, and Haskell came out of it.

Functional programming model

The English name is Functional ProgrammingWe can also call it functional programming, or you can call it your own way.

No one has given an official definition of the term Functional programming. However, when we say Haskell is a functional programming language, we usually think of the following two things:

  • WHAT IS FIRST, that is, functions have the same value as any other variable.
  • Programming in Haskell often revolves around evaluating expression statements rather than executing those expressions.

Transparent references

This property can be explained:

  • Everything from variables to data structures cannot be changed. If you noticed, the String class in Java also has this property.
  • Expressions are not available side effects, such as changing the value of global variables or displaying the output to the screen.
  • A function called the same number of times and passed the same parameter always produces the same result.

Hearing it can be difficult to understand. Leibniz’s law explains this property as follows: arithmetic by assignment '=' can replace everything anywhere. For example, if x is defined by the equation x = 42, then the name x and number 42 can be used anywhere but because they are “2 but 1”.

Lazy – Lazy

Lazy here means, if the result of an expression is not used anywhere, then Haskell will not execute that expression. That is why it has some of the following consequences (or consequences):

  • Defining a control structure is incredibly easy.
  • Defining an infinite number of data structures is a possibility.
  • The evaluation of memory complexity and time is extremely… complicated 🙂

Static data type

All expressions in Haskell have type, and Haskell ARE NOT check the type during compilation. The code with type error is not compiled by Haskell, thus making the program run faster.

High order function

Higher order formula (Higher-Order Function) is also a property in the Javascript language that allows a function to be used as an argument to another function, and also to be used as the return value of a function.

Hope this helps!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *