Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup 'deriving's #154

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cedar-lean/Cedar/Data/Int64.lean
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ if h : Int64.lt i₁ i₂ then isTrue h else isFalse h
instance int64Le (i₁ i₂ : Int64) : Decidable (i₁ ≤ i₂) :=
if h : Int64.le i₁ i₂ then isTrue h else isFalse h

deriving instance Repr for Int64
deriving instance DecidableEq for Int64
deriving instance Repr, DecidableEq for Int64

end Int64

Expand Down
5 changes: 2 additions & 3 deletions cedar-lean/Cedar/Data/Map.lean
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ namespace Cedar.Data

inductive Map (α : Type u) (β : Type v) where
| mk : List (α × β) -> Map α β
deriving Repr
deriving instance DecidableEq, Repr, Inhabited for Map
deriving Repr, DecidableEq, Repr, Inhabited

namespace Map

Expand Down Expand Up @@ -111,4 +110,4 @@ theorem in_list_in_map {α : Type u} (k : α) (v : β) (m : Map α β) :

end Map

end Cedar.Data
end Cedar.Data
6 changes: 3 additions & 3 deletions cedar-lean/Cedar/Data/Set.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ namespace Cedar.Data

inductive Set (α : Type u) where
| mk (l : List α)
deriving Repr
deriving instance DecidableEq, Repr, Inhabited, Lean.ToJson for Set
deriving Repr, DecidableEq, Inhabited, Lean.ToJson

namespace Set

Expand Down Expand Up @@ -106,6 +105,7 @@ def singleton {α} (a : α) : Set α :=

def foldl {α β} (f : α → β → α) (init : α) (s : Set β) : α :=
s.elts.foldl f init

----- Props and Theorems -----

instance [LT α] : LT (Set α) where
Expand Down Expand Up @@ -157,4 +157,4 @@ theorem make_eq_if_eqv [LT α] [DecidableLT α] [StrictLT α] (xs ys : List α)

end Set

end Cedar.Data
end Cedar.Data
6 changes: 2 additions & 4 deletions cedar-lean/Cedar/Spec/Entities.lean
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def Entities.attrsOrEmpty (es : Entities) (uid : EntityUID) : Map Attr Value :=

----- Derivations -----

deriving instance Repr for EntityData
deriving instance DecidableEq for EntityData
deriving instance Inhabited for EntityData
deriving instance Repr, DecidableEq, Inhabited for EntityData

end Cedar.Spec
end Cedar.Spec
13 changes: 4 additions & 9 deletions cedar-lean/Cedar/Spec/Expr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,11 @@ inductive Expr where

----- Derivations -----

deriving instance Repr for Var
deriving instance Repr for UnaryOp
deriving instance Repr for BinaryOp
deriving instance Repr for Expr
deriving instance Repr, DecidableEq for Var
deriving instance Repr, DecidableEq for UnaryOp
deriving instance Repr, DecidableEq for BinaryOp
deriving instance Repr, Inhabited for Expr

deriving instance Inhabited for Expr

deriving instance DecidableEq for Var
deriving instance DecidableEq for UnaryOp
deriving instance DecidableEq for BinaryOp

mutual

Expand Down
5 changes: 2 additions & 3 deletions cedar-lean/Cedar/Spec/Ext.lean
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def Ext.lt : Ext → Ext → Bool

----- Derivations -----

deriving instance Repr for Ext
deriving instance DecidableEq for Ext
deriving instance Repr, DecidableEq for Ext

instance : LT Ext where
lt := fun x y => Ext.lt x y
Expand All @@ -54,4 +53,4 @@ instance : Coe Decimal Ext where
instance : Coe IPAddr Ext where
coe a := .ipaddr a

end Cedar.Spec
end Cedar.Spec
3 changes: 1 addition & 2 deletions cedar-lean/Cedar/Spec/Ext/IPAddr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ def IPNet.lt : IPNet → IPNet → Bool

----- IPNet deriviations -----

deriving instance Repr for IPNet
deriving instance DecidableEq for IPNet
deriving instance Repr, DecidableEq, Inhabited for IPNet

instance : LT IPNet where
lt := fun d₁ d₂ => IPNet.lt d₁ d₂
Expand Down
5 changes: 2 additions & 3 deletions cedar-lean/Cedar/Spec/ExtFun.lean
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def call : ExtFun → List Value → Result Value

----- Derivations -----

deriving instance Repr for ExtFun
deriving instance DecidableEq for ExtFun
deriving instance Repr, DecidableEq for ExtFun

end Cedar.Spec
end Cedar.Spec
28 changes: 7 additions & 21 deletions cedar-lean/Cedar/Spec/Policy.lean
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,13 @@ def Scope.bound : Scope → Option EntityUID

----- Derivations -----

deriving instance Repr for Effect
deriving instance Repr for Scope
deriving instance Repr for PrincipalScope
deriving instance Repr for ResourceScope
deriving instance Repr for ActionScope
deriving instance Repr for Policy

deriving instance DecidableEq for Effect
deriving instance DecidableEq for Scope
deriving instance DecidableEq for PrincipalScope
deriving instance DecidableEq for ResourceScope
deriving instance DecidableEq for ActionScope
deriving instance DecidableEq for Policy

deriving instance Inhabited for Effect
deriving instance Inhabited for Scope
deriving instance Inhabited for PrincipalScope
deriving instance Inhabited for ResourceScope
deriving instance Inhabited for ActionScope
deriving instance Inhabited for Policy
deriving instance Repr, DecidableEq, Inhabited for Effect
deriving instance Repr, DecidableEq, Inhabited for Scope
deriving instance Repr, DecidableEq, Inhabited for PrincipalScope
deriving instance Repr, DecidableEq, Inhabited for ResourceScope
deriving instance Repr, DecidableEq, Inhabited for ActionScope
deriving instance Repr, DecidableEq, Inhabited for Policy

deriving instance Lean.ToJson for PolicyID

end Cedar.Spec
end Cedar.Spec
6 changes: 2 additions & 4 deletions cedar-lean/Cedar/Spec/Request.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ structure Request where
resource : EntityUID
context : Map Attr Value

deriving instance Repr for Request
deriving instance DecidableEq for Request
deriving instance Inhabited for Request
deriving instance Repr, DecidableEq, Inhabited for Request

end Cedar.Spec
end Cedar.Spec
11 changes: 3 additions & 8 deletions cedar-lean/Cedar/Spec/Response.lean
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ structure Response where

----- Derivations -----

deriving instance Repr for Decision, Response
deriving instance Repr, DecidableEq, Lean.ToJson for Decision
deriving instance Repr, DecidableEq, Lean.ToJson for Response

deriving instance DecidableEq for Decision
deriving instance DecidableEq for Response

deriving instance Lean.ToJson for Decision
deriving instance Lean.ToJson for Response

end Cedar.Spec
end Cedar.Spec
25 changes: 6 additions & 19 deletions cedar-lean/Cedar/Spec/Value.lean
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,14 @@ instance : Coe Value (Result (Data.Set Value)) where

----- Derivations -----

deriving instance Repr for Except
deriving instance Repr for Error
deriving instance Repr for Name
deriving instance Repr for EntityType
deriving instance Repr for EntityUID
deriving instance Repr for Prim
deriving instance Repr, DecidableEq, BEq for Except
deriving instance Repr, DecidableEq for Error
deriving instance Repr, DecidableEq, Inhabited for Name
deriving instance Repr, DecidableEq, Inhabited for EntityType
deriving instance Repr, DecidableEq, Inhabited for EntityUID
deriving instance Repr, DecidableEq, Inhabited for Prim
deriving instance Repr for Value

deriving instance DecidableEq for Except
deriving instance DecidableEq for Error
deriving instance DecidableEq for Name
deriving instance DecidableEq for EntityType
deriving instance DecidableEq for EntityUID
deriving instance DecidableEq for Prim

deriving instance Inhabited for Name
deriving instance Inhabited for EntityType
deriving instance Inhabited for EntityUID
deriving instance Inhabited for Prim

deriving instance BEq for Except

mutual

Expand Down
4 changes: 1 addition & 3 deletions cedar-lean/Cedar/Spec/Wildcard.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ namespace Cedar.Spec
inductive PatElem where
| star
| justChar (c : Char)
deriving Repr
deriving instance DecidableEq for PatElem
deriving instance Inhabited for PatElem
deriving Repr, DecidableEq, Inhabited

abbrev Pattern := List PatElem

Expand Down
2 changes: 0 additions & 2 deletions cedar-lean/UnitTest/IPAddr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def testsForInvalidStrings :=
testInvalid "F:AE::F:5:F:F:0/01" "no leading zeros"
]

deriving instance Inhabited for IPNet

private def parse! (str : String) : IPNet :=
match parse str with
| .some ip => ip
Expand Down