CSE 130 Lecture Notes - Lecture 9: Syntactic Sugar, Type Inference, Blowup

30 views3 pages

Document Summary

Member x (y:ys) = if x == y. Because we cannot guarantee that for all a"s, we can use the == to compare elements of type a. Parametric polymorphism does not work else member x ys. Single algorithm that works on values of any type. Type variable may be replaced by any type. We want a form of overloading (i. e. ad-hoc polymorphism ) Type inference: square :: int int. Fully polymorphic (not the right soln) (==) :: a a bool. Eqtype polymorphism (sml) (==) :: a== a== bool. Member :: a== [a==] bool a== are special variables restricted to types w/ equality. Only things that we baked into the language can be compared! Lack the ability to customize data types into our own classes of types (+) :: int int int, (+) :: float float float, etc. Type classes - generalize eqtypes to arbitrary types: provide concise types to describe overloaded functions.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents