mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 04:09:10 +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
|