From 7e5e960be729843a49ebc87a358a9c3c254668fa Mon Sep 17 00:00:00 2001 From: Iden Craven Date: Mon, 14 Jan 2019 08:08:20 -0700 Subject: [PATCH] Update index.md (#24545) Added an introduction to the structure of a Haskell function --- guide/english/haskell/index.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/guide/english/haskell/index.md b/guide/english/haskell/index.md index 0410264256..48c169f92d 100644 --- a/guide/english/haskell/index.md +++ b/guide/english/haskell/index.md @@ -26,6 +26,20 @@ stack exec my-project-exe ``` A word of cautious, try not to use stack install 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