Friday 29 April 2016

Haskell Tutorial

Introduction To Haskell

      Introduction to Haskell
      Different implementations Of Haskell
      Setting up Haskell in your machine
      Introduction to GHCi
      Hello World program using ghci
      Hello World program using ghc command
      ghc Vs ghci
      Hello World program using runghc command
      First parallel Haskell program
      Variables
      Naming, coding conventions
      Define variable at GHCi prompt
      Specifying type to a variable
      Comments

Functions

      Introduction To Functions
      Functions take priority over anything else
      Total and Partial functions
      map function
      Currying
      Higher order function
      const function

Little Exploration on GHCi

      GHCi: Get all the bindings in GHCi prompt
      :set : Change settings
      Enable warnings at GHCi prompt
      GHCi: Safely ignore warnings while running
      unset: Unset options
      it: Special variable stores the result of an expression
      GHCi: multi line expressions
      show language: Get the language standard version
      Prelude module
      Working with Negative numbers

Hackage, Hoogle, Hayoo

      Hackage: Haskell collection of libraries
      Haskell API Search Engines: Hoogle, Hayoo

Basic Building Blocks

      where clause
      let expression
      Lambda: Anonymous functions
      do block
       >> : Chain IO actions
      >>= : Use result of first IO action in second
      return: Convert a to IO a
      $ operator: Avoid parentheses
      Infix functions

Operators

      Arithmetic operators
            Difference between rem Vs mod
            Difference between ^ and **
            div vs /
            abs: Get the absolute value of a number
            negate: Change the sign of a number
      Comparison operators
      Boolean operators
      Operators are functions
      Operator precedence, associativity rules
      Define custom operators

Partial Application, Sections, Guards

      Partial applications
      Sections
      Point-free style
      Guards
      Combine where and guards

Type System

      Type system
      Get the type of variable
      Specifying signature to a function
      type variables
      Type inference
      Numeric types
      Boolean types
      Char datatype
      String data type

Lists, Tuples

      lists
            Concatenate two lists
            Strings are lists internally
            cycle: Infinite list
            repeat: Produce infinite list
            replicate: Replicate elements
            Define range of elements
            List Comprehensions
            Student course registration using list comprehensions
            XTransformListComp : Enhance List extensions
            ParallelListComp: Traverse several lists at a time
            As-patterns (@)
      tuples

Conditional Expressions, let.i block, indentation, Basic IO

      if else expression
      if-else if-else construct
      functions: piece-wise definition
      case expressions
      let..in block
      Indentations
      Explicit Structuring
      Composition of functions
      Import a module in a source file
      Print data to console
      Read Input from console
      Loops, Recursion

Custom Types

      Custom types
      Generate String representation of custom type
      Adding type variables to custom types
      type: make type synonyms
      Types of constructors
      Declare constructor as an infix operator
      Enumerations
      newtype keyword
      Phantom type
      Smart constructors
      Pattern Matching
      Wildcard pattern
      Custom types using record syntax
      View Patterns
      Polymorphism
      Maybe: programming with out null

filter, fold, Tail Recursion

      filter function
      fold pattern
      Tail recursion

Lazy Evaluation

      How Lazy evaluation works in Haskell
      Problems with Lazy evaluation
      Is Haskell a purely lazy language?
      Lazy Vs Eager evaluation
      Working with infinite structures

GHC Extension, folding, Reporting Errors

      How to enable GHC extensions
      Bangpatterns
      folding : foldl, foldr functions
      Reporting Errors using error function
      undefined

Libraries, Modules

      Libraries
      Modules
      Qualified imports
      Hiding definitions from a module
      Renaming imports
      Combining renaming and limited imports
      Modules: Restrict functions to expose
      Import types, name constructor, value constructors
      Writing standalone programs
      command line arguments to standalone (main) program
      List all the functions in a module

Type Classes

      Type classes
      How to define a type class
      Defining type class instances
      Built in type classes
      Type class Show: Convert values to Strings
      Read: Convert string to some other data type
      readLn: Gives whatever type of data you want
      Serialization using read and show
      Eq type class
      Ord type class
      Multi-parameter type class
      type classes extension
      Number related type classes

IO

      Standard Input Output functions
      putStr, putStrLn: Write string to standard output
      unit : Return nothing from IO action
      putChar: Write a character to the standard output
      print : print data to console
      print Vs putStrLn
      getLine: Read line from standard input
      getChar: Read character
      interact: Interact with input

File Handling

      File handling
      openFile: Read contents of a file
      File Buffering operations
      readFile : Get file data as a string
      Write string to a file
      appendFile: Append data to file
      hClose: Closing files
      withFile: Perform operation on file handle
      hFileSize : Get the size of file
      hSetFileSize: Truncate the file
      hTell: Get current position of handle
      hSeek: Change file handle position
      hIsOpen: Check whether file handle is open (or) not
      hIsClosed: Check whether file handle is closed or not
      hIsReadable: Check whether file handle is readable or not
      hIsWritable: Check whether file is writable (or) not
      hIsSeekable: Check whether handle is seekable (or) not
      hIsEOF: Check end of file
      hGetLine: Read file line by line
      hGetChar: Read a charcater from file
      hLookAhead: Return next character from file
      hGetContents: Get the file data as string
      hPutChar: Write character to a file
      hPutStr: Write a string to a file
      hPutStrLn: Write a string to a file
      hPrint: Write data to file
      Working with temporary files
      Working with binary files
      Specify encoding and decoding
      mkTextEncoding: Handling illegal characters

Working with Directories

      Exploring System.Directory package
      createDirectory: Create a directory
      createDirectoryIfMissing: Create directory if not exist
      removeDirectory: Remove an existing directory
      removeDirectoryRecursive : Remove directories and sub directories
      renameDirectory: Rename a directory
      getDirectoryContents: List all entries in the directory including special entries ., ..
      getCurrentDirectory: Get current working directory
      setCurrentDirectory: Change working directory
      getHomeDirectory: get user home directory
      listDirectory: List all entries in directory
      withCurrentDirectory: Work with given directory
      getTemporaryDirectory: Get the directory for temporary files
      removeFile: Remove file
      renameFile: Rename file
      copyFile: Copy file
      canonicalizePath: Replace ., .. with actual path
      makeAbsolute: Convert path to absolute path
      makeRelativeToCurrentDirectory: Construct a path relative to current directory
      Search for files
      findExecutable : Get the path of given executable
      findExecutables: Get all the paths of executable file
      findExecutablesInDirectories: Search for an executable in given directories
      findFile: Search for a file in given directories
      findFiles: Search for a file in given directories
      findFilesWith: Get all the files that satisfiy given property
      Work with file permissions
      Working with file access and modification times

Functor, Monads, Monoids

      Functors
      Monoids
      Benefits of Monoid in Haskell
      Monads

Miscellaneous

      Installing hoogle tool on your machine
      cabal: Specify the version of package to install
      load module
      chr: Convert integer to character
      ord: Convert character to integer
      Convert int (number) to string
      List all commands
      Change working directory


Previous                                                 Next                                                 Home

No comments:

Post a Comment