Demystifying Function Sub-typing

schedule Nov 16th 11:25 - 11:45 AM place Meeting Room 1 people 27 Interested

What is a Type for a function? When can you say that a function is a sub-type of another function? Why should you even bother?

Function sub-typing is one of the most confusing areas of FP. In this talk, I'll take a deep dive and explain the core concepts of function types which applies to many different languages. More than just explaining the mere rules, I will be deriving those rules in a step-by-step fashion till the eureka moment so that you will never be confused again.

The topics covered:

  1. Sub-typing basics
  2. Covariance & Contravariance
  3. Function sub-typing
  4. Implementation gotchas in different languages (Java, Scala, Haskell, JavaScript)
 
 

Outline/Structure of the Talk

  • 5 mins
    1. Essential basics and an invented programming language for our discussion
    2. What is sub-typing
  • 8 mins
    1. Covariance & Contravariance
    2. Deriving the function sub-type
  • 7 mins
    1. Usage examples for function sub-types
    2. Implementation caveats in popular systems

Learning Outcome

Strong understanding of function sub-typing, useful in library design and contract modelling.

Target Audience

Anyone using FP, preferably strongly typed languages like Scala, Haskell etc.

Prerequisites for Attendees

Have a good understanding of FP concepts, especially First Class Functions and types.

schedule Submitted 4 months ago

Public Feedback

comment Suggest improvements to the Speaker
  • Naresh Jain
    By Naresh Jain  ~  2 months ago
    reply Reply

    Hi Anish,

    Thanks for your proposal.

    Can you please update the outline section of your proposal with a time-wise breakup of how you plan to use 20 mins for the 6 topics you've highlighted.

    Also, to help the program committee to understand your presentation style, can you please upload a video of your past presentations? If you don't have one, can you record a small 1 mins trailer of your talk and share the link to the same?

    • Naresh Jain
      By Naresh Jain  ~  1 month ago
      reply Reply

      Hi Anish, any updates?

      • Anish George
        By Anish George  ~  1 month ago
        reply Reply

        Here is the time wise break-up:

        • 5 mins for basics and made up language
        • 5 mins for variance and goal
        • 10 mins to derive the function subtype
        • 10 mins of examples and pitfalls

        I'll post the video soon

        • Naresh Jain
          By Naresh Jain  ~  1 month ago
          reply Reply

          Thanks for sharing the video and breakup, Anish. Your talk is proposed for 20 mins, but your outline is already 30 mins. Do you want to update the talk to 45 mins? Please update your main proposal with these details to allow the program team to make a final decision. Thanks.

          • Anish George
            By Anish George  ~  1 month ago
            reply Reply

            Hi Naresh, I don't think this talk is all of 45mins long. its a very small topic... Here is the revised timeline:

            • 5 mins for
              • basics
              • made up language
              • goal
            • ~8 mins for
              • Variance
              • Function subtype derivation
            • ~7 mins for examples and pitfalls
            • Anish George
              By Anish George  ~  1 month ago
              reply Reply

              Hi Naresh, any updates?

      • Anish George
        By Anish George  ~  1 month ago
        reply Reply

        Here is the video https://drive.google.com/file/d/1zb-34goOwPYCoeX97964lRA28alOjWMV/view?usp=sharing


  • Liked Anupam Jain
    keyboard_arrow_down

    Anupam Jain - Typesafe Functional SQL

    45 Mins
    Talk
    Intermediate

    We'll discuss how to use strongly typed functional programming to build a typesafe and highly declarative DSL to generate SQL, that allows better abstractions and minimises runtime errors. We'll focus on type systems, and build an intuition for row types and how it guarantees correctness for SQL. I'll cover some parts of actual SQL generation.

    A similar talk was given at IIIT Delhi earlier, however that was more geared towards beginners to Functional Programming (link below). I plan to give a more intermediate level talk this time.

  • Liked Siddharth Bhat
    keyboard_arrow_down

    Siddharth Bhat - Monad-bayes: Probabilistic programming in haskell, tutorial & implementation

    Siddharth Bhat
    Siddharth Bhat
    Student
    IIIT Hyderabad
    schedule 2 months ago
    Sold Out!
    20 Mins
    Case Study
    Intermediate

    We take a dive into probabilistic programming, beginning with a high-level explanation of what probabilistic programming is. We then continue to see how to use the monad-bayes library for performing tasks such as regression in a bayesian formalism. We also look into the implementation of the library, which involves performing an interesting sampling method (markov-chain-monte-carlo) on a very unique space (the space of computational traces of the program). We finally end with next-steps for the haskell community to improve in the probablistic programming space, ala pyro for python

    Here is our tiny re-implementation of monad-bayes, boiled down to the essentials: https://github.com/bollu/shakuni

    Paper on which the talk is based on: http://mlg.eng.cam.ac.uk/pub/pdf/SciGhaGor15.pdf

  • Liked Ankit Jain
    keyboard_arrow_down

    Ankit Jain - Designing powerful real-time systems using Scala and Akka

    45 Mins
    Talk
    Intermediate

    Sky BML (Beat/Meet/Lose) is a streaming system that produces real time Competitive Intelligence about our Lodging Supply.

    This competitive information is being used, among others, for Market Managers to negotiate with hotels for better rates and avail. Competitiveness is proportional to the share of BML Losses that Expedia incurs. This is why Market Managers focus their energies on minimising losses.

    However, it is not easy to understand why losses occur and consequently their resolution takes proportionately long.Our system tries to simplify this and hence accelerate resolution of losses.

    To develop this system, we fully leveraged the power of different functional features of Scala and used Structured Spark Streaming as the processing engine in combination with Clustering(for better app supervision and lifecycle management of the nodes).

    Similarly, some of the complex challenges are solved very naturally using functional programming features of easily. We had this complex problem of traversing a decision tree (based on conditional expressions) and then evaluating the child nodes(which are also expressions) with different lookup services responsible for mapping the symbols used in Expressions.

    I will be discussing in detail on how we tactically use Functional Programming concepts like Implicits, currying, High-Order Functions to get rolling with this problem with ease.

    Similarly, I will discuss on the way we have apply OOP principles to handle different kinds of inputs(streaming/batch) with minimal code duplication.

    Overall, it will be lot of fun to discuss the way to think about our problems and how our thinking is shaped by different concepts available in Scala.

  • Liked Harmeet Singh
    keyboard_arrow_down

    Harmeet Singh - Type System: The Beauty And The Beast

    45 Mins
    Talk
    Intermediate

    The type system plays an important role in building type-safe applications that reduce runtime exceptions and developer mistakes. This sophisticated system is leveraged by Scala’s most famous functional libraries, such as Scala-Cats and ScalaZ. This feature-rich system allows implementing pure functional programming on the JVM. It is a beast due to its complex syntax, as it prevents developers from exploring its beautiful aspects like partially applying types in Scala. In this talk, we will tame the beast and use its beauty to solve real-life issues faced during coding. Our examples will be based on generics, constraints, type lambdas, and the kind projector plugin.

    The following are the learning objectives of this talk:

    1. Practical use cases of the type system using real-life coding.

    2. Implementing custom higher kinded types and handling partially applied types via type lambdas and the kind projector plugin.

  • Liked Siddharth Kulkarni
    keyboard_arrow_down

    Siddharth Kulkarni - Functional Programming in Rust Lang

    45 Mins
    Talk
    Beginner

    Rust is a new systems programming language that is garnering a lot attention from higher level programmers alike. It has a strong type system that enables some interesting functional programming patterns. Through this talk, I would like to demonstrate the Zero Cost Functional Abstractions in Systems Programming and Otherwise. The talk assumes intermediate level knowledge of FP principles and basic understanding of Rust Lang.

  • Liked ganesan arunachalam
    keyboard_arrow_down

    ganesan arunachalam - What the hell is monad? Why should you care?

    ganesan arunachalam
    ganesan arunachalam
    Developer
    ThoughtWorks
    schedule 2 months ago
    Sold Out!
    45 Mins
    Talk
    Intermediate

    Real world applications are hard to imagine without side effects such as writing to a DB or UI. IO-monads were introduced into the Haskell language to write programs in a robust way. And we have been using monads in our day to day job without even knowing those are monads such as IEnumerable/IObservable in languages like C#, Java.

    This talk is to give a basic understanding about monads and why should we care about that, and a little bit about onion/clean architecture.