Update index.md (#24545)
Added an introduction to the structure of a Haskell function
This commit is contained in:
committed by
Christopher McCormack
parent
b6e24d4e14
commit
7e5e960be7
@ -27,6 +27,20 @@ stack exec my-project-exe
|
||||
|
||||
A word of cautious, try not to use stack install <package> even though it will install package globally, this is not recommended as different versions of packages are compatible with different versions of GHC. Hence using local copy of package using stack build is best way to follow.
|
||||
|
||||
## Structure of a Haskell Function
|
||||
A Haskell function declaration has a name and type identifiers
|
||||
```haskell
|
||||
name :: type
|
||||
name = expression
|
||||
```
|
||||
For example, this function squares an Integer
|
||||
```haskell
|
||||
square :: Integer -> Integer
|
||||
square n = n * n
|
||||
```
|
||||
|
||||
The last type value is the return value, in the case above it takes a single integer and returns a single integer.
|
||||
|
||||
## Hello World
|
||||
|
||||
```haskell
|
||||
|
Reference in New Issue
Block a user