{- Haskel example code for CMSC 631 presentation by Kevin Atkinson and John Simmons -} -- *** SLIDE 6 *** -- lazy evaluation: this is legal to type, but not to evaluate s6_1 = 1/0 -- *** SLIDE 8 *** -- type inference s8_1 = 5+3.0 -- s81 gets 8.0 -- some pre-defined types s8_2::Integer s8_2 = 1 s8_3::Char s8_3 = 'A' s8_4::String s8_4 = "Foo" s8_5::Float s8_5 = 1.0 -- a polymorphic type s8_6 :: a -> [a] s8_6(x) = x:[] -- *** SLIDE 9 *** -- some user-defined types type S9_1 = String data S9_2 = Red|Green|Blue type S9_3 = [Integer] -- an int list s9_3::S9_3 s9_3 = [1,2,3,4,5] type S9_4 = (Float,Float) -- a tuple s9_4::S9_4 s9_4 = (1.0,2.0) data S9_5 = MyRecord {first::Integer,second::Float} -- a record s9_5::S9_5 s9_5 = MyRecord {first = 9, second = 4.5} -- a type class class MyClass a where foo :: a -> Integer -- a subclass class (MyClass b) => MySubClass b where bar :: b -> String -- an instance instance MyClass Integer where foo x = x::Integer -- *** SLIDE 10 *** data RealFloat a => Complex a = !a :+ !a -- *** SLIDE 11 *** s11_1 = 1:s11_1 -- an infinite list of 1's