Idris2/tests/refc/refc002/RecordProjection.idr

22 lines
407 B
Idris

module RecordProjection
record Name where
constructor MkName
firstName : String
lastName : String
(.fullName) : Name -> String
name.fullName = name.firstName ++ " " ++ name.lastName
johnSmith : Name
johnSmith = MkName
{ firstName = "John"
, lastName = "Smith"
}
main : IO ()
main = assert_total $ do
putStrLn johnSmith.firstName
putStrLn johnSmith.lastName
putStrLn johnSmith.fullName