/- From https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Ensuring.20naive.20purity Will revisit later -/ -- def natFun : Nat β ByteArray := -- IO.getRandomBytes 8 |>.run' -- -- | k => match (IO.getRandomBytes 8 |>.run' ()) with -- -- | some bytes => bytes.toUInt64BE!.toNat % 256 -- -- | none => k -- -- #eval natFun 4 /- type mismatch EStateM.set s has type EStateM ?m.273 (?m.61 β EStateM.Result ?m.60 ?m.61 ?m.61) PUnit : Type but is expected to have type Id Unit : Type -/ -- def ohNo : Unit := Id.run do -- let s β EStateM.get -- IO.println "Oh no" -- EStateM.set s -- #eval ohNo def anyway : IO Unit := do letβEStateM.get letEStateM.get: {Ξ΅ Ο : Type} β EStateM Ξ΅ Ο Οx := β (Β·.x: NattoUInt64BE!.toUInt64BE!: ByteArray β UInt64toNat % 256) <$>toNat: UInt64 β NatIO.getRandomBytesIO.getRandomBytes: USize β IO ByteArray8 -- EStateM.set s let8: USizey := β (Β·.y: NattoUInt64BE!.toUInt64BE!: ByteArray β UInt64toNat % 256) <$>toNat: UInt64 β NatIO.getRandomBytesIO.getRandomBytes: USize β IO ByteArray8 -- EStateM.set s let8: USizez := β (Β·.z: NattoUInt64BE!.toUInt64BE!: ByteArray β UInt64toNat % 256) <$>toNat: UInt64 β NatIO.getRandomBytesIO.getRandomBytes: USize β IO ByteArray88: USizeIO.println f!"{IO.println: {Ξ± : Type} β [inst : ToString Ξ±] β Ξ± β IO Unitx} {x: Naty} {y: Natz}"z: Natanywayanyway: IO Unitexample :example: 1 + 1 = 21 +1: Nat1 =1: Nat2 :=2: NatGoals accomplished! πGoals accomplished! πstructureGoals accomplished! πTwo whereTwo: Typex :x: Two β NatNatNat: Typeproperty :property: β (self : Two), self.x = 2x =x: Nat2 := by decide def2: Nata :a: TwoTwo := {x :=Two: Type2} def2: Natb :=b: TwoGoals accomplished! π2 def2: Natc :c: TwoTwo := β¨Two: Type2,2: Natrflβ© -- hope to omit rflrfl: β {Ξ± : Type} {a : Ξ±}, a = a