Advanced functional programming with Scala

Coordinator:

Juan Manuel Serrano

Instructor:

Javier Fuentes

Location:
Parque Científico Universidad Carlos III de Madrid
Start:
13/1/17
Duration:
Fridays, 16:00h. Four consecutive sessions of four hours each.
Language:
Spanish

Overview

This course provides a comprehensive introduction to three programming styles endorsed by functional programming: datatype generic, applicative and monadic programming. We also delve into the concept of algebra and compare the two major ways of representing algebras in functional programming: either as object-algebras, using type classes, or as F-algebras, using algebraic data types, natural transformations, and so forth. Throughout the course, we use Scala and its awesome ecosystem of frameworks and libraries for functional programming. In particular, we built upon the generic programming library shapeless, and the type class libraries scalaz and cats. We also make ocassional reference to property-based testing and the Scalacheck library. For each programming style, we describe the kinds of problems they are intended to solve, their constituent software abstractions and their implementation by different libraries.

Audience

  • Scala Programmers with moderate knowledge of functional programming, tired of reinventing the wheel each time they must define a new monad or instantiate a type class, for instance
  • Programmers with deep knowledge of functional programming, but moderate knowledge of Scala and its ecosystem for functional programming

    Objectives

    At the end of the course, attendees should be able to:
  • Identify the different modularity techniques endorsed by functional programming: from parametric and ad-hoc polimorphism (i.e. type classes), to datatype generic programming, languages and interpreters, etc.
  • Understand the design patterns used in the implementation of the signature, laws, derived operations, instances and syntactic facilities of type classes, both in Scalaz and Cats.
  • Understand how monad transformers work, and the common transformer instances of monadic type classes: StateT (MonadState), EitherT (MonadError), etc.
  • Understand the concept of algebra in functional programming, and the different ways of representing them: either with type classes (object algebras) or algebraic data types (F-algebras).
  • Understand Generalised ADTs, natural transformations and Free monads, and know when to use these ADT-based representations instead of object algebras and Church encodings.
  • Understand the differences between the applicative and monadic (i.e. imperative) programming styles, their major applications, and their support in scalaz and cats!
  • Understand the concept of "free structure" and use it in the implementation of monadic and applicative languages
  • Understand the role of heterogeneous lists (aka HList) and coproducts to abstract away the particular shapes of algebraic data types (ADTs), and implement generic algorithms that work at this level of abstraction, e.g. to automatically derive type classes. All of this using shapeless!
  • Understand the overall internal architecture of Shapeless, scalaz and cats, and the most advanced Scala tricks used in their implementation, thus taking your Scala expertise to the next level
  • Learn more functional programming yourself!

    Outline

    • Type class libraries: Scalaz & Cats
      • Scalaz & Cats overview
      • Type classes: Monad, MonadState, MonadError, etc.
      • Monad transformers: StateT, EitherT, etc.
    • Algebras and functional programming
      • F-algebras and object-algebras
      • GADTs and natural transformations
      • Free structures: free monoids and free monads
    • Applicative programming
      • Applicative functors
      • Traversables
      • Free applicatives
    • Datatype generic programming
      • Shapeless architecture
      • HList & Coproduct representations of ADTs
      • Automatic type class derivation

    Organization

    • The course runs over four consecutive Fridays, each session running for four hours. Setup instructions will be made available well in advance, so that attendees can bring their laptops properly configured to the classroom.
    • Explanations during sessions will alternate between slides and live coding, with a preference for the later. Small exercises and challenges will be proposed after each major block of contents, and solved in the classroom.
    • The course will be taught in Spanish.
    • After each session, attendees will be encouraged to complete a number of additional exercises on Github. Habla Computing trainers will provide feedback via code reviews for those who completed this coursework in due time. A chat room will also be made available to offer guidance and foster collaboration among course attendees.

    About the coordinator

    The course is coordinated by Juan Manuel Serrano. Juan Manuel is CTO and co-founder of Habla Computing. He has been using Scala for the last six years in real-world applications for the banking sector, and has extensive experience in consultancy projects with Scalaz, Cats, and other frameworks of the Scala ecosystem. He founded and manages the Madrid Scala Meetup group and is member of the organizing committee of lambda.world, the premier Spanish conference of functional programming for the software practitioner. Prior to joining Habla Computing, Juan Manuel was a University teacher for more than fifteen years in different computer science and software engineering degrees.

  • Terms of use

    Welcome to the Habla Computing S.L. website
    Owner: Habla Computing, S.L.
    Address: Villalobos, 20, 13A 28018 Madrid
    Tel. (+34) 91 172 68 52; fax. (+34) 91 172 68 52
    E-mail: info@hablapps.com
    Registry Data: Madrid Commerce Registry, Volume 27,693, Sheet 12, Section 8, Page M-499100, dated April 12, 2010, first registration.
    C.I.F.: B-85933729

    Terms of Use
    The conditions herein regulate the use of this website. By accessing, browsing, or using this Web site imply that user have read, understood, and agree, unconditionally, to be bound by these terms.
    Habla Computing may, without notice to you, at any time revise and/or update these Terms of Use and any other information contained in this Web site. Habla Computing may also make changes in the products, services, or programs described in this site at any time without previous notice.
    Habla Computing reserves the right to deny, suspend, interrupt or cancel access or use of this website, either completely or partially, for those users or visitors found to be in non-compliance with any of the conditions set forth in this Legal Notice.

    General
    Specifically, the reproduction, transformation, distribution, communication, public dissemination and, in general, any form of development, using any procedure whatsoever, of all or part of the contents of this website, as well as any corresponding design and manner of presentation of the materials included herein are strictly prohibited. Said development shall only be permitted if Habla Computing issues written authorization of the same and only as long as appropriate reference is made to the sole property of Habla Computing. Notwithstanding the foregoing, any software and other materials that are made available for downloading, access, or other use from this site with their own license terms, conditions, and notices will be governed by such terms, conditions, and notices.
    The decompilation, disassembly, reverse engineering, sub-licensing or transfer of any kind, translation or execution of work derived from the computer programs required for functioning, access and use of this website, and of the services described in the contents, as well as the execution of any of the development activities described in the previous paragraph, whether related to all or part of such programs, is also strictly prohibited. The user of this website must abstain from deleting, modifying, avoiding or manipulating any protection device or security systems that may be installed herein.
    The brand names, commercial names and distinctive symbols are the sole property of Habla Computing. Access to the website does not imply the granting of any express or implied rights under any patents, trademarks, copyrights, or other proprietary or intellectual property rights.

    Hyperlinks to other sites
    The hyperlinks or links included in this website can lead the user to other third party sites, over which Habla Computing has no control. Habla Computing shall not be held liable for the contents or the state in which said sites are found. Access to the said sites using this website also does not, in any way whatsoever, imply that Habla Computing either recommends or approves of corresponding contents or use of such Web site.
    Habla Computing is not a party to or responsible for any transactions user may enter into with third parties, even if you learn of such parties (or use a link to such parties) from a Habla Computing site. Accordingly, user acknowledge and agree that Habla Computing is not responsible for the availability of such external sites or resources, and is not responsible or liable for any content, services, products, or other materials on or available from those sites or resources.
    It is up to user to take precautions to protect themselves from viruses, worms, trojan horses, and other potentially destructive programs, and to protect your information as you deem appropriate.

    Linking to this site
    All links to this Web site must be approved in writing by Habla Computing, except that Habla Computing consents to links in which the link and the pages that are activated by the link do not: (a) create frames around any page on this Web site or use other techniques that alter in any way the visual presentation or appearance of any content within this site; (b) misrepresent your relationship with Habla Computing; (c) imply that Habla Computing approves or endorses you, your Web site, or your service or product offerings; and (d) present false or misleading impressions about Habla Computing or otherwise damage the goodwill associated with the Habla Computing name. As a further condition to being permitted to link to this site, you agree that Habla Computing may at any time, in its sole discretion, terminate permission to link to this Web site. In such event, you agree to immediately remove all links to this Web site.

    Modifications
    Habla Computing reserves the right, at any time, to modify, enlarge or temporarily suspend the website presentation, configuration, technical specifications and services unilaterally and without previous notice.
    Also reserves the right to modify the terms of use, as well as any other specific conditions, set forth herein at any time.

    Confidential information
    Habla Computing does not want to receive confidential or proprietary information from user through our Web site. Please note that any information or material sent to Habla Computing will be deemed NOT to be confidential. By sending Habla Computing any information or material, you grant Habla Computing an unrestricted, irrevocable license to copy, reproduce, publish, upload, post, transmit, distribute, publicly display, perform, modify, create derivative works from, and otherwise freely use, those materials or information. You also agree that Habla Computing is free to use any ideas, concepts, know-how, or techniques that you send us for any purpose. However, we will not release your name or otherwise publicize the fact that you submitted materials or other information to us unless we obtain your permission to use your name.

    Liability Exclusion
    Whoever uses the website does so at their own expense and risk. All materials, information, products, software, programs, and services are provided “as is” with no warranties or guarantees whatsoever, neither explicit nor implied, and can be modified or updated without previous notice. Habla Computing, its associates and employees shall not be held liable for the errors or omissions that could exist within the contents of either this website or other contents to which access can be gained using the same. Habla Computing, its associates and employees shall also not be held liable for either any damages arising from the use of this website or any activity undertaken as a result of the information made available herein. Accordingly, user should confirm the accuracy and completeness of all posted information before making any decision related to any services, products, or other matters described in this site.
    Habla Computing does not guarantee the absence of viruses, worms or other harmful computer elements that could cause damage or alter the computer system in the electronic documents or user files included herein. As a result, Habla Computing shall not be held liable for any user or third party damages or losses arising from such elements. Furthermore, Habla Computing shall not be held liable for or guarantee the availability and continuity of access to this web site. Habla Computing shall also not guarantee that this website is secure or error-free. It shall be the user’s responsibility to have the appropriate tools available for detecting and disinfecting harmful or damaging computer programs.
    In no event will Habla Computing be liable to any party for any direct, indirect, incidental, special, exemplary or consequential damages of any type whatsoever related to or arising from this web site or any use of this web site, or of any site or resource linked to, referenced, or accessed through this web site, or for the use or downloading of, or access to, any materials, information, products, or services, including, without limitation, any lost profits, business interruption, lost savings or loss of programs or other data. The user is fully aware of, and voluntarily accepts the fact that they are fully liable for any consequences arising from any use of any part of the contents herein, materials, information, products, software, programs, or services, so at their own discretion and risk. User will be solely responsible for any damages that may result, including loss of data or damage to your computer system.
    The user shall be held liable for losses and damages of any kind that Habla Computing could suffer as a result of incompliance with the obligations set forth herein.
    Additional or different terms, conditions, and notices may apply to specific materials, information, products, software, and services offered through this Web site. In the event of any conflict, such additional or different terms, conditions, and notices will prevail over these Terms of Use.

    Legislation
    Under any and all circumstances, the use conditions set forth herein shall be governed by Spanish Law.