Idris2/tests/idris2/record006/Fld.idr

56 lines
1.5 KiB
Idris
Raw Normal View History

2020-08-27 21:43:51 +03:00
module Fld
namespace SuperDog
public export
record SuperDog where
constructor MkDog
supername : String
age : Int
weight : Int
namespace OrdinaryDog
public export
record OrdinaryDog where
constructor MkDog
name : String
age : Int
weight : Int
record Other a where
constructor MkOther
{imp : String}
fieldA : a
fieldB : b
2020-08-28 10:09:16 +03:00
myDog_notWorking0 : record MkDog {name = "Sam"} -- Not all fields are covered
2020-08-27 21:43:51 +03:00
2020-08-28 10:09:16 +03:00
myDog_notWorking1 : record MkDog {age = 3, name1 = "Sam"} -- No constructor with name `MkDog`
-- has field `name1`
2020-08-28 12:17:50 +03:00
myDog_notWorking2 : record MkDog
2020-08-27 21:43:51 +03:00
{ age = 4
, age = 2
, weight = 12
, name = "Sam" } -- Duplicate names
2020-08-28 12:17:50 +03:00
2020-08-27 21:43:51 +03:00
myDog : ?
myDog = record MkDog { age = 4
, weight = 12
, name = "Sam" } --Disambiguation by unique fields
mySuperDog : ?
mySuperDog = record MkDog { age = 3
, weight = 10
, supername = "Super-Sam" } --Disambiguation by unique fields
other : ? -- Elaborates as (MkOther (fromString "hi") (the Int 1) {imp = fromString "Secret string"})
other = record MkOther {fieldB = the Int 1, fieldA = "hi"} {imp = "Secret string"}
same : record MkDog {name = "Rex", age = 2, weight = 10} = MkDog "Rex" 2 10
same = Refl
2020-08-28 12:17:50 +03:00
record Unit where
constructor MkUnit
unit : Unit
unit = record MkUnit {}