Commit e4a420e9 authored by Jan Rasmus Tikovsky 's avatar Jan Rasmus Tikovsky

Updated tests for new record syntax

parent 3b6530c8
module HaskellRecords where
data R a = C { l :: Int, x :: a }
| D { l :: Int }
-- data R a = C { l :: Int, x :: a }
-- | D { l :: Int }
--
-- -- construction
-- r1 :: R Bool
-- r1 = C { l = 42, x = True }
--
-- r2 :: R a
-- r2 = C {}
--
-- -- pattern matching
-- fun :: R a -> Bool
-- fun C { l = 42 } = True
--
-- fun2 :: R a -> Bool
-- fun2 C {} = False
--
-- -- update
-- upd :: R Bool -> R Bool
-- upd r = r { x = False, l = 0 }
--
-- -- selection
-- getL :: R a -> Int
-- getL r = l r
-- construction
r1 :: R Bool
r1 = C { l = 42, x = True }
data R = C { label :: Int, l2 :: Bool }
r2 :: R a
r2 = C {}
r :: R
r = C { label = 42, l2 = True }
-- pattern matching
fun :: R a -> Bool
fun C { l = 42 } = True
r' :: R
r' = r { label = 73 }
fun2 :: R a -> Bool
fun2 C {} = False
-- update
upd :: R Bool -> R Bool
upd r = r { x = False, l = 0 }
-- selection
getL :: R a -> Int
getL r = l r
\ No newline at end of file
unr :: R
unr = C { l2 = True }
module RecordTest where
module RecordTest (Agent, lastName, trueIdentity, mike) where
import HaskellRecords
data Person = Person { firstName :: String, lastName :: String }
| Agent { lastName :: String, trueIdentity :: Person }
r = C 73 False
\ No newline at end of file
mike :: Person
mike = Person { firstName = "Mike", lastName = "Smith" }
\ No newline at end of file
module RecordTest2 where
import RecursiveRecords
import RecordTest
updLN = mike { lastName = "Doe" }
showR :: R Int -> String
showR r = show (r :> f1) ++ (r :> f2)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment