Row polymorphism crash course

// Works for any record with the fields width, height : Float
area2d v = v.width * v.height
f : forall row1. {a: Int, …row1} -> Int
g : forall row2. {b: String, …row2} -> Int
h x = f x + g x
f : {a: Int, …row3} -> Int
g : {b: String, …row4} -> Int
x : {a: Int, …row3}
x : {b: String, …row4}
{a: Int, …row3} = {b: String, …row4}
row3 = {b: String, …row5}
row4 = {a: Int, …row5}
{a: Int, b: String, …row5} = {b: String, a: Int, …row5}
{a: Int, b: String, …row5} = {a: Int, b: String, …row5}
h : forall row5. {a: Int, b: String, …row5} -> Int
f : {a: Int, …row3} -> Int
g : {a: String, …row4} -> Int
{a: Int, …row3} = {a: String, …row4}
Int = String

--

--

--

MSc Computer Science, working with functional programming in the industry — github.com/ahnfelt

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Alumni Spotlight: Kristen Lingwood

An overview of the Core Data stack

Configuring Micro-services Behind AWS API Gateway and Securing it with oAuth 2.0

What Are the Key Benefits of Using Kubernetes? Why Would You Use It? How Is It Different (Better)?

What Are the Key Benefits of Using Kubernetes? Why Would You Use It? How Is It Different (Better)?

Create an array and access array elements in PHP

Wroclove.rb 2019 highlights for Ruby developers- datarockets

The 10 Most Popular Alexa Skills in 2018 on Voiciety

How is a day in a developer’s life

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Joakim Ahnfelt-Rønne

Joakim Ahnfelt-Rønne

MSc Computer Science, working with functional programming in the industry — github.com/ahnfelt

More from Medium

concept of recursion

How can I tell if my dog is sick?

Book review: Fermat’s Last Theorem

Why Manual Payroll is a Big Risk in Global Expansion