Haskell Modules

Description

Haskell Modules
TABARES ROMERO DIEGO MAURICIO
Mind Map by TABARES ROMERO DIEGO MAURICIO, updated more than 1 year ago
TABARES ROMERO DIEGO MAURICIO
Created by TABARES ROMERO DIEGO MAURICIO over 4 years ago
6
0

Resource summary

Haskell Modules
  1. concepts
    1. Haskell Modules are a collection of related functions, types and type classes.
      1. Standard Haskell module is named prelude
        1. Modules are used to manipulate lists, concurrent programming, complex numbers, etc.
    2. why use modules
      1. Modules becomes reusables if they are enough generic
        1. Modules make programs loosely coupled
          1. Modules make more manageable by having it split into several parts
          2. How to used
            1. Aggregate import clause and the name of Module at the beginning of your script
              1. Add as imports as you need in separate lines
                1. When you do import Data.List, all the functions that Data.List exports become available in the global namespace
              2. From ghci terminal you may use :m + <name module>
                1. Annotations:

                  • |
                2. If you just need a couple of functions from a module, you can selectively import just those functions.
                  1. You might use hiding to exclude functions within modeles
                    1. You can use qualified imports to deal with clashes and add an alias to imports
                    2. Haskell Included modules
                      1. Data.List
                        1. imterparse takes an element and a list and put the first arguent and put it between each element of the second argument list
                          1. Intercalate function receives a list and a list of list and intercalate each element
                            1. transpose function transposes a list of list
                              1. concat function flatten a list of list in a single list
                                1. concatMap: mapping a functionin a list and the concatenate
                                  1. 'and' and 'or' functions evaluates a predicate and return a boolean if condition accomplish
                                      1. any and all take a predicate and then check if any or all the elements in a list satisfy the predicate
                                          1. splitAt takes a number and a list. It then splits the list at that many elements
                                            1. takeWhile takes elements from a list while the predicate holds and then when an element is encountered that doesn't satisfy the predicate, it's cut off
                                              1. dropWhile drops all the elements while the predicate is true
                                              2. Data.Map
                                                1. Association lists (also called dictionaries) are lists that are used to store key-value pairs where ordering doesn't matter.
                                                  1. The fromList function takes an association list
                                                    1. empty represents an empty map. It takes no arguments, it just returns an empty map.
                                                      1. insert takes a key, a value and a map and returns a new map that's just like the old one, only with the key and value inserted
                                                        1. null checks if a map is empty.
                                                          1. size reports the size of a map.
                                                            1. singleton takes a key and a value and creates a map that has exactly one mapping.
                                                              1. member is a predicate takes a key and a map and reports whether the key is in the map or not.
                                                                1. keys and elems return lists of keys and values respectively. keys is the equivalent of map fst . Map.toList and elems is the equivalent of map snd . Map.toList.
                                                                  1. fromListWith is a cool little function. It acts like fromList, only it doesn't discard duplicate keys but it uses a function supplied to it to decide what to do with them. Let's say that a girl can have several numbers and we have an association list set up like this.
                                                                    1. insertWith is to insert what fromListWith is to fromList. It inserts a key-value pair into a map, but if that map already contains the key, it uses the function passed to it to determine what to do.
                                                                  2. Data.Char
                                                                    1. The Data.Char module does what its name suggests. It exports functions that deal with characters. It's also helpful when filtering and mapping over strings because they're just lists of characters.
                                                                      1. This module exports a bunch of predicates over characters
                                                                        1. isControl checks whether a character is a control character.
                                                                          1. isSpace checks whether a character is a white-space characters. That includes spaces, tab characters, newlines, etc.
                                                                            1. isLower and is Upper check is a character is upper or Lower case
                                                                              1. isAlpha checks whether a character is a letter.
                                                                                1. isAlphaNum checks whether a character is a letter or a number.
                                                                                  1. isPrint checks whether a character is printable. Control characters, for instance, are not printable.
                                                                                    1. isDigit checks whether a character is a digit.
                                                                                      1. isLetter checks whether a character is a letter.
                                                                                        1. isNumber checks whether a character is numeric.
                                                                                          1. isSymbol checks whether a character is a fancy mathematical or currency symbol.
                                                                                            1. isSeparator checks for Unicode spaces and separators.
                                                                                              1. isAscii checks whether a character falls into the first 128 characters of the Unicode character set.
                                                                                                1. isAsciiUpper or isAsciiLower check if is an ASCII is upper or lower case
                                                                                            2. Data.Set
                                                                                              1. Sets are kind of like a cross between lists and maps. All the elements in a set are unique. And because they're internally implemented with trees (much like maps in Data.Map), they're ordered.
                                                                                                1. The fromList function works much like you would expect.
                                                                                                  1. We can use the difference function to see which letters are in the first set but aren't in the second one and vice versa.
                                                                                                    1. we can see all the unique letters used in both sentences by using union.
                                                                                                2. Making our own modules
                                                                                                  1. Haskell allow us as many other lenguages to create our own modules
                                                                                                    1. We should create a file named with *.hs, the fist letter of the file should be in upper case
                                                                                                      1. At the beginning of a module, we specify the module name
                                                                                                        1. Then we defined the functions the will be included within de module
                                                                                                          1. Following we shold implement the functions we alredy define at the beginning of the module
                                                                                                  Show full summary Hide full summary

                                                                                                  Similar

                                                                                                  Spanish: Talking About Everyday Things
                                                                                                  Niat Habtemariam
                                                                                                  To Kill A Mockingbird
                                                                                                  tommarlin15
                                                                                                  Study Plan
                                                                                                  mlanders
                                                                                                  Bayonet Charge flashcards
                                                                                                  katiehumphrey
                                                                                                  AS Biology - Types of Carbohydrates.
                                                                                                  pheebzda
                                                                                                  Hitler's Chancellorship
                                                                                                  c7jeremy
                                                                                                  History - Treaty of Versailles
                                                                                                  suhhyun98
                                                                                                  The Endocrine System
                                                                                                  DrABC
                                                                                                  organic chemistry
                                                                                                  osgoconqr
                                                                                                  Carbohydrates
                                                                                                  kevinlinkovoor
                                                                                                  Účto Fífa 4/6
                                                                                                  Bára Drahošová