Mapa mental
Haskell

Contenido del mapa
Haskell
Is based on LISP programming language
- Its research was started at 1990 as a committee-designed language
- The first version was released at 1998 as Haskell 98
- Its research was started at 1990 as a committee-designed language
The first and most important compiler is Glasgow Haskell Compiler
- You can download it and start learning for free
- It comes with an interactive environment (GHCi)
- And with a project build tool (Cabal)
- And a dependency manager
- Enter it using "ghci" command
- Exit using the ":q" command
- If you see
- Prelude>
- Means only Haskell standard library is loaded
- *Main>
- A project is compiled and loaded
- Prelude>
- And with a project build tool (Cabal)
The Hello World Program
- main = putStrLn "Hello, World"
- The "putStrLn" function receives a String as argument and print it out to the standard output followed by a new line (\n)
- main = putStrLn "Hello, World"
The Syntax
- Program entry point does not have arguments (like C)
- Functions
- functionName arg1 arg2 = code
- Function and argument names must start with lowercase letter
- Comments
- Instead of "//" we use "--"
- User defined types
- type String = [Char]
- Whenever the compiler sees String as a type, it replaces with with [Char]
- Completely new data type
- data Color = Red | Green | Blue
- Kinda Java enums
- if statement
- Guards
- Kinda multi-way if statements (else if)
- Guards
- Lists
- Generate lists using [X..Y]
Types
- Numeric (Num)
- Integer
- Floating
- Double
- Compiler has type inference
- List
- String
- Char
- Boolean
- Tuple
- Typeclasses
- Like Java interfaces
- All types must start with uppercase letter
- You can define new typeclasses
- Allow us to attach a set of functions to a data type
- Monad is a typeclass
- Numeric (Num)
Allows cleaner and shorter implementations
- binary functions to inline functions
- Enclose them between backticks (`)
- a `mod` b
- Enclose them between backticks (`)
- The Maybe type
- Returns None or a value
- Forces programmer to handle both escenarios
- Returns None or a value
- binary functions to inline functions
Create a project
- stack new test
- Creates a new project called "test"
- Run it with "stack exec"
- Creates a new project called "test"
- stack new test
Conclusion
- Haskell has a lot of features
- Cannot cover them all here
- Haskell has a lot of features
Imágenes y archivos del mapa
Información
- Descripción
- Mapa Mental sobre Haskell, creado por ALVARO ANTONIO STAGG RAMIREZ el 25/08/2021.
- Creado por
- ALVARO ANTONIO STAGG RAMIREZ
- Visitas
- 0
- Valoración