# Some reading problem

**URL:** <https://discourse.haskell.org/t/some-reading-problem/918>\
**Category:** Learn\
**Created:** [October 8, 2019, 8:29am UTC](https://discourse.haskell.org/t/some-reading-problem/918 "2019-10-08T08:29:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PoroDev](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/porodev/32/611_2.png) [@PoroDev](https://discourse.haskell.org/u/PoroDev)\
**Post date:** [October 8, 2019, 8:29am UTC](https://discourse.haskell.org/t/some-reading-problem/918/1 "2019-10-08T08:29:43Z")

</div>

Hi everybody,

I’m new to Haskell, and i don’t really know how to read that part of a code i found :

data E = Var String  
| App E E  
| Abs String E  
deriving (Eq, Show)

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [October 8, 2019, 9:22am UTC](https://discourse.haskell.org/t/some-reading-problem/918/2 "2019-10-08T09:22:33Z")

</div>

This code is saying there is a data type called `E` (that is the type). That type has three ways of constructing it: `Var :: String -> E`, `App :: E -> E -> E` and `Abs :: String -> E -> E`. Using those constructors you can make an abstract syntax tree, for example:

`example1 = App (Abs "x" (Var "x")) (Var "y") :: E`

In this case the type `E` probably stands for lambda calculus **E** xpression. Are you familiar with the lambda calculus? Then the example I gave above stands for the application of the identity function to the unbound variable `y`.

The last line `deriving (Eq, Show)` asks the compiler to automatically derive instances of the `Eq` type class, which means that the functions `(==)` and `(!=)` can be used on this data type, and the `Show` type class, which means that the `show` function can be used on this data type.

---

<div class="post-metadata">

**Author:** ![PoroDev](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/porodev/32/611_2.png) [@PoroDev](https://discourse.haskell.org/u/PoroDev)\
**Post date:** [October 8, 2019, 9:24am UTC](https://discourse.haskell.org/t/some-reading-problem/918/3 "2019-10-08T09:24:11Z")

</div>

Thanks for the answer, I’m not really familiar with the lambda calculus but i’m learning it 🙂

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [October 8, 2019, 9:29am UTC](https://discourse.haskell.org/t/some-reading-problem/918/4 "2019-10-08T09:29:47Z")

</div>

By the way, these are called algebraic data types if you want to search for them. The Haskell wiki also has a page for them: [https://wiki.haskell.org/Algebraic\_data\_type](https://wiki.haskell.org/Algebraic_data_type).

---

<div class="post-metadata">

**Author:** ![PoroDev](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/porodev/32/611_2.png) [@PoroDev](https://discourse.haskell.org/u/PoroDev)\
**Post date:** [October 8, 2019, 9:44am UTC](https://discourse.haskell.org/t/some-reading-problem/918/5 "2019-10-08T09:44:12Z")

</div>

I’ve got a program that parses lambda-calculus, I think can I contact you somewhere so you can help me understanding it ?
