ou Comment j’ai appris à aimer les types
Arnaud Bailly - @dr_c0d3
2019-09-24
#beginners
elm-lang
List a
selectEntries : (Account -> Bool) -> Vect k Entries -> Balance isLeapYear : Year -> Bool toDate : String -> String -> String -> Either String Date
data Balance : Type where Zero : Balance Bal : (n : Amount) -> (d : Direction) -> Balance
data List a = Nil | Cons a (List a)
interface ToSExp a where toSExp : a -> SExp ToSExp SExp where toSExp = id ToSExp Unit where toSExp () = SList []
type family Answer q = a | a -> q where Answer QCM = Int Answer Grade = Double Answer OpenQuestion = Text
Factors : UnitType -> Type Factors Armored = StdFactors Factors Artillery = Arty Factors AntiTank = Pak Factors HQ = Arty Factors SupplyColumn = Unit
data CmdREPL : (segment : GameSegment) -> Type where Cmd : (cmd : Command segment) -> CmdREPL segment Qry : (ToSExp res) => (qry : Query res) -> CmdREPL segment
data BookOfAccounts : Type where BookTransactions : (txs : Vect k Transaction) -> BookOfAccounts
data Query : (result : Type) -> Type where SupplyPath : (unitName : String) -> Query (Either QueryError (List Pos)) TerrainMap : Query Map
Eq Balance where (==) b b' = ?hole
- + Accounting.Core.hole [P] `-- b : Balance b' : Balance -------------- Accounting.Core.hole : Bool
record GameUnit where constructor MkGameUnit nation : Nation unitType : UnitType name : String move : Nat hit : Bool combat : Factors unitType
neighbours1_test : (neighbours (Hex 3 3) = [ Hex 2 3, Hex 3 2 , Hex 4 3, Hex 4 4 , Hex 3 4, Hex 2 4] ) neighbours1_test = Refl
data Entries : Type where MkEntries : (entries : Vect n Entry) -> { auto need2Entries : LTE 2 n } -> { auto balanced : balance entries = Zero } -> Entries
notPosZIsNotAbsZ : ((y = Pos 0) -> Void) -> ((absZ y = 0) -> Void) notPosZIsNotAbsZ = contrapositive absZIsPosZ
contrapositive : (a -> b) -> (Not b -> Not a) contrapositive = flip (.)
absZIsPosZ : (absZ y = 0) -> (y = Pos 0) absZIsPosZ {y = (Pos Z)} Refl = Refl absZIsPosZ {y = (Pos (S _))} Refl impossible absZIsPosZ {y = (NegS _)} Refl impossible
https://forms.gle/C1h63ymmoqdceeme7