mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 20:51:43 +03:00
22 lines
407 B
Idris
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
|