Skip to content

Commit

Permalink
[ feat for #108 ] IsLawfulNum instance for Int
Browse files Browse the repository at this point in the history
  • Loading branch information
pmbittner authored and jespercockx committed Jul 9, 2024
1 parent 71e8ab3 commit 7d5bd11
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/Haskell/Law/Num/Int.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Haskell.Law.Num.Int where

open import Haskell.Prim using (refl; tt)
open import Haskell.Prim.Num
open import Haskell.Prim.Int
open import Haskell.Prim.Word

open import Haskell.Law.Num
open import Haskell.Law.Num.Word

instance
open NumHomomorphism
open NumEmbedding

iNumEmbeddingIntWord : NumEmbedding Int Word intToWord int64
+-hom (hom iNumEmbeddingIntWord) (int64 _) (int64 _) = refl
*-hom (hom iNumEmbeddingIntWord) (int64 _) (int64 _) = refl
minus-ok (hom iNumEmbeddingIntWord) = tt
negate-ok (hom iNumEmbeddingIntWord) = tt
fromInteger-ok (hom iNumEmbeddingIntWord) = tt
0-hom (hom iNumEmbeddingIntWord) = refl
1-hom (hom iNumEmbeddingIntWord) = refl
negate-hom (hom iNumEmbeddingIntWord) (int64 _) = refl
embed iNumEmbeddingIntWord (int64 _) = refl

iLawfulNumInt : IsLawfulNum Int
iLawfulNumInt = map-IsLawfulNum intToWord int64 iNumEmbeddingIntWord iLawfulNumWord
1 change: 1 addition & 0 deletions lib/Haskell/Law/Num/Word.agda
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS --allow-unsolved-metas #-}
module Haskell.Law.Num.Word where

open import Haskell.Prim
Expand Down

0 comments on commit 7d5bd11

Please sign in to comment.