SlideShare a Scribd company logo
1 of 6
Download to read offline
List type
Dmytro Mitin
https://stepik.org/course/Introduction-to-programming-
with-dependent-types-in-Scala-2294/
March 2017
Dmytro Mitin List type
List type
Haskell
data List a = Nil | Cons a (List a)
Scala
sealed trait List[+A]
case object Nil extends List[Nothing]
case class Cons[A](head: A, tail: List[A]) extends List[A]
Java
public interface List<A> {}
public class Nil<A> implements List<A> {}
public class Cons<A> implements List<A> {
private final A head;
private final List<A> tail;
}
Dmytro Mitin List type
List type
1 Type Formation
Γ A : ∗
Γ List A : ∗
2 Constructors
Γ A : ∗
Γ nil : List A
Γ h : A Γ t : List A
Γ cons h t : List A
3 Eliminator
Γ c1 : C Γ, h : A, t : List A c2 : C
Γ, x : List A caseList(x)(c1, λht.c2) : C
x match { case Nil => c1; case Cons(h, t) => c2(h, t) }
Dmytro Mitin List type
List type
4 Computation rules (”β-reduction“)
Γ c1 : C Γ, h : A, t : List A c2 : C
Γ caseList(nil)(c1, λht.c2) ≡ c1 : C
Γ c1 : C Γ, h : A, t : List A c2 : C
Γ h : A Γ t : List A
Γ caseList(cons h t )(c1, λht.c2) ≡ c2[h ← h , t ← t ] : C
5 Uniqueness principle (”η-conversion“)
Dmytro Mitin List type
ProvingGround
git clone https://github.com/siddhartha-gadgil/ProvingGround.git
cd ProvingGround
sbt mantle/test:console
import TLImplicits.
import shapeless.
val Nat = "Nat" :: Type
val NatInd = ("0" ::: Nat) |: ("succ" ::: Nat -->>: Nat) =: Nat
val zero :: succ :: HNil = NatInd.intros
val one = succ(zero)
val two = succ(one)
val three = succ(two)
val A = "A" :: Type
val ListA = "List(A)" :: Type
val ListAInd = ("nil" ::: ListA) |: ("cons" ::: A ->>: ListA -->>:
ListA ) =: ListA
val nil :: cons :: HNil = ListAInd.intros
Dmytro Mitin List type
ProvingGround
val recLN = ListAInd.rec(Nat)
val a = "a" :: A
val as = "as" :: ListA
val n = "n" :: Nat
val size = recLN(zero)(a :-> (as :-> (n :-> succ(n) )))
val a1 = "a1" :: A
val a2 = "a2" :: A
val list = cons(a)(cons(a1)(cons(a2)(nil)))
size(list) == three
Dmytro Mitin List type

More Related Content

What's hot

Linked list searching deleting inserting
Linked list searching deleting insertingLinked list searching deleting inserting
Linked list searching deleting insertingSamsil Arefin
 
[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例Shinji Miyazato
 
Functional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative ProgrammersFunctional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative ProgrammersChris
 
09 - Scala. Product type
09 - Scala. Product type09 - Scala. Product type
09 - Scala. Product typeRoman Brovko
 
Roslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesRoslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesMichael Step
 
Coderstrust Presentation on C Language
Coderstrust Presentation on C LanguageCoderstrust Presentation on C Language
Coderstrust Presentation on C LanguageSrabon Sabbir
 
Write a program to show the example of hybrid inheritance.
Write a program to show the example of hybrid inheritance.Write a program to show the example of hybrid inheritance.
Write a program to show the example of hybrid inheritance.Mumbai B.Sc.IT Study
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersDr. Loganathan R
 
Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...
Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...
Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...hwbloom38
 
Railroading into Scala
Railroading into ScalaRailroading into Scala
Railroading into ScalaNehal Shah
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Dr. Loganathan R
 
Applications of Stack in DSA
Applications of Stack in DSAApplications of Stack in DSA
Applications of Stack in DSAAftab Mirza
 
Objective c
Objective cObjective c
Objective cStijn
 

What's hot (20)

Slides
SlidesSlides
Slides
 
Linked list searching deleting inserting
Linked list searching deleting insertingLinked list searching deleting inserting
Linked list searching deleting inserting
 
[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例[TechPlayConf]Rekognition導入事例
[TechPlayConf]Rekognition導入事例
 
Functional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative ProgrammersFunctional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative Programmers
 
09 - Scala. Product type
09 - Scala. Product type09 - Scala. Product type
09 - Scala. Product type
 
เมธอด
เมธอด เมธอด
เมธอด
 
Roslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesRoslyn and C# 6.0 New Features
Roslyn and C# 6.0 New Features
 
Coderstrust Presentation on C Language
Coderstrust Presentation on C LanguageCoderstrust Presentation on C Language
Coderstrust Presentation on C Language
 
Write a program to show the example of hybrid inheritance.
Write a program to show the example of hybrid inheritance.Write a program to show the example of hybrid inheritance.
Write a program to show the example of hybrid inheritance.
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...
Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...
Part II: 2-Dimensional Array file name: lab1part2.cpp (10 points) Write a C++...
 
Railroading into Scala
Railroading into ScalaRailroading into Scala
Railroading into Scala
 
Overview of c (2)
Overview of c (2)Overview of c (2)
Overview of c (2)
 
Coincheck cash
Coincheck cashCoincheck cash
Coincheck cash
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
2015.3.12 the root of lisp
2015.3.12 the root of lisp2015.3.12 the root of lisp
2015.3.12 the root of lisp
 
Concept of c
Concept of cConcept of c
Concept of c
 
C workshop day 6
C workshop day 6C workshop day 6
C workshop day 6
 
Applications of Stack in DSA
Applications of Stack in DSAApplications of Stack in DSA
Applications of Stack in DSA
 
Objective c
Objective cObjective c
Objective c
 

Similar to 05 - Scala. List type

04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbersRoman Brovko
 
08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. SimulacrumRoman Brovko
 
13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)Roman Brovko
 
Делаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе ShapelessДелаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе ShapelessВадим Челышов
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and HaskellHermann Hueck
 
Algebraic Data Types and Origami Patterns
Algebraic Data Types and Origami PatternsAlgebraic Data Types and Origami Patterns
Algebraic Data Types and Origami PatternsVasil Remeniuk
 
Towards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The BayTowards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The BayBoldRadius Solutions
 
Seductions of Scala
Seductions of ScalaSeductions of Scala
Seductions of ScalaDean Wampler
 
Demystifying Type Class derivation with Shapeless
Demystifying Type Class derivation with ShapelessDemystifying Type Class derivation with Shapeless
Demystifying Type Class derivation with ShapelessYurii Ostapchuk
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systemsleague
 
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.2 book - Part 23 of 84The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.2 book - Part 23 of 84Mahmoud Samir Fayed
 
( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf
( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf
( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdfaristogifts99
 
Practical scalaz
Practical scalazPractical scalaz
Practical scalazoxbow_lakes
 

Similar to 05 - Scala. List type (20)

04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers
 
08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum
 
Sigma type
Sigma typeSigma type
Sigma type
 
13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)
 
Thesis PPT
Thesis PPTThesis PPT
Thesis PPT
 
Thesis
ThesisThesis
Thesis
 
Делаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе ShapelessДелаем пользовательское Api на базе Shapeless
Делаем пользовательское Api на базе Shapeless
 
Typeclasses
TypeclassesTypeclasses
Typeclasses
 
New lambdas
New lambdasNew lambdas
New lambdas
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
 
Algebraic Data Types and Origami Patterns
Algebraic Data Types and Origami PatternsAlgebraic Data Types and Origami Patterns
Algebraic Data Types and Origami Patterns
 
Towards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The BayTowards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The Bay
 
Seductions of Scala
Seductions of ScalaSeductions of Scala
Seductions of Scala
 
Demystifying Type Class derivation with Shapeless
Demystifying Type Class derivation with ShapelessDemystifying Type Class derivation with Shapeless
Demystifying Type Class derivation with Shapeless
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
C++11
C++11C++11
C++11
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systems
 
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.2 book - Part 23 of 84The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.2 book - Part 23 of 84
 
( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf
( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf
( PLEASE SHOW HOW TO IMPLEMENT THE DELETION FUNCTION )SAMPLE OUTPU.pdf
 
Practical scalaz
Practical scalazPractical scalaz
Practical scalaz
 

More from Roman Brovko

Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task NetworkingRoman Brovko
 
Networking essentials lect3
Networking essentials lect3Networking essentials lect3
Networking essentials lect3Roman Brovko
 
Gl embedded starterkit_ethernet
Gl embedded starterkit_ethernetGl embedded starterkit_ethernet
Gl embedded starterkit_ethernetRoman Brovko
 
Networking essentials lect2
Networking essentials lect2Networking essentials lect2
Networking essentials lect2Roman Brovko
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1Roman Brovko
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flashRoman Brovko
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2CRoman Brovko
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uartRoman Brovko
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorRoman Brovko
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwmRoman Brovko
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsRoman Brovko
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_worldRoman Brovko
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisitesRoman Brovko
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advancedRoman Brovko
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advancedRoman Brovko
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advancedRoman Brovko
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окруженияRoman Brovko
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advancedRoman Brovko
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basicsRoman Brovko
 

More from Roman Brovko (20)

Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task Networking
 
Networking essentials lect3
Networking essentials lect3Networking essentials lect3
Networking essentials lect3
 
Gl embedded starterkit_ethernet
Gl embedded starterkit_ethernetGl embedded starterkit_ethernet
Gl embedded starterkit_ethernet
 
Networking essentials lect2
Networking essentials lect2Networking essentials lect2
Networking essentials lect2
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flash
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
 
Glesk worshop
Glesk worshopGlesk worshop
Glesk worshop
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensor
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwm
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttons
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_world
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisites
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advanced
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advanced
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advanced
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advanced
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basics
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 

05 - Scala. List type

  • 2. List type Haskell data List a = Nil | Cons a (List a) Scala sealed trait List[+A] case object Nil extends List[Nothing] case class Cons[A](head: A, tail: List[A]) extends List[A] Java public interface List<A> {} public class Nil<A> implements List<A> {} public class Cons<A> implements List<A> { private final A head; private final List<A> tail; } Dmytro Mitin List type
  • 3. List type 1 Type Formation Γ A : ∗ Γ List A : ∗ 2 Constructors Γ A : ∗ Γ nil : List A Γ h : A Γ t : List A Γ cons h t : List A 3 Eliminator Γ c1 : C Γ, h : A, t : List A c2 : C Γ, x : List A caseList(x)(c1, λht.c2) : C x match { case Nil => c1; case Cons(h, t) => c2(h, t) } Dmytro Mitin List type
  • 4. List type 4 Computation rules (”β-reduction“) Γ c1 : C Γ, h : A, t : List A c2 : C Γ caseList(nil)(c1, λht.c2) ≡ c1 : C Γ c1 : C Γ, h : A, t : List A c2 : C Γ h : A Γ t : List A Γ caseList(cons h t )(c1, λht.c2) ≡ c2[h ← h , t ← t ] : C 5 Uniqueness principle (”η-conversion“) Dmytro Mitin List type
  • 5. ProvingGround git clone https://github.com/siddhartha-gadgil/ProvingGround.git cd ProvingGround sbt mantle/test:console import TLImplicits. import shapeless. val Nat = "Nat" :: Type val NatInd = ("0" ::: Nat) |: ("succ" ::: Nat -->>: Nat) =: Nat val zero :: succ :: HNil = NatInd.intros val one = succ(zero) val two = succ(one) val three = succ(two) val A = "A" :: Type val ListA = "List(A)" :: Type val ListAInd = ("nil" ::: ListA) |: ("cons" ::: A ->>: ListA -->>: ListA ) =: ListA val nil :: cons :: HNil = ListAInd.intros Dmytro Mitin List type
  • 6. ProvingGround val recLN = ListAInd.rec(Nat) val a = "a" :: A val as = "as" :: ListA val n = "n" :: Nat val size = recLN(zero)(a :-> (as :-> (n :-> succ(n) ))) val a1 = "a1" :: A val a2 = "a2" :: A val list = cons(a)(cons(a1)(cons(a2)(nil))) size(list) == three Dmytro Mitin List type