mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-21 02:31:50 +03:00
[ refactor ] move SizeChange
to a separate file
This commit is contained in:
parent
db87cef0ad
commit
d76361e0f6
@ -5,6 +5,7 @@ modules =
|
||||
Algebra,
|
||||
Algebra.Preorder,
|
||||
Algebra.Semiring,
|
||||
Algebra.SizeChange,
|
||||
Algebra.ZeroOneOmega,
|
||||
|
||||
Compiler.ANF,
|
||||
|
43
src/Algebra/SizeChange.idr
Normal file
43
src/Algebra/SizeChange.idr
Normal file
@ -0,0 +1,43 @@
|
||||
module Algebra.SizeChange
|
||||
|
||||
import Algebra.Semiring
|
||||
|
||||
import Libraries.Text.PrettyPrint.Prettyprinter
|
||||
|
||||
public export
|
||||
data SizeChange = Smaller | Same | Unknown
|
||||
|
||||
export
|
||||
Semigroup SizeChange where
|
||||
-- Same is a neutral
|
||||
Unknown <+> _ = Unknown
|
||||
Same <+> c = c
|
||||
_ <+> Unknown = Unknown
|
||||
Smaller <+> _ = Smaller
|
||||
|
||||
export
|
||||
Monoid SizeChange where
|
||||
neutral = Same
|
||||
|
||||
export
|
||||
Show SizeChange where
|
||||
show Smaller = "Smaller"
|
||||
show Same = "Same"
|
||||
show Unknown = "Unknown"
|
||||
|
||||
export
|
||||
Eq SizeChange where
|
||||
Smaller == Smaller = True
|
||||
Same == Same = True
|
||||
Unknown == Unknown = True
|
||||
_ == _ = False
|
||||
|
||||
export
|
||||
Ord SizeChange where
|
||||
compare Smaller Smaller = EQ
|
||||
compare Smaller _ = LT
|
||||
compare _ Smaller = GT
|
||||
compare Same Same = EQ
|
||||
compare Same _ = LT
|
||||
compare _ Same = GT
|
||||
compare Unknown Unknown = EQ
|
@ -7,6 +7,8 @@ import public Core.Name
|
||||
import public Core.Options.Log
|
||||
import public Core.TT
|
||||
|
||||
import public Algebra.SizeChange
|
||||
|
||||
import Data.IORef
|
||||
import Data.String
|
||||
|
||||
@ -260,45 +262,6 @@ Show DefFlag where
|
||||
show (ConType ci) = "contype " ++ show ci
|
||||
show (Identity x) = "identity " ++ show x
|
||||
|
||||
public export
|
||||
data SizeChange = Smaller | Same | Unknown
|
||||
|
||||
export
|
||||
Semigroup SizeChange where
|
||||
-- Unknown is a 0
|
||||
-- Same is a neutral
|
||||
_ <+> Unknown = Unknown
|
||||
Unknown <+> _ = Unknown
|
||||
c <+> Same = c
|
||||
_ <+> Smaller = Smaller
|
||||
|
||||
export
|
||||
Monoid SizeChange where
|
||||
neutral = Same
|
||||
|
||||
export
|
||||
Show SizeChange where
|
||||
show Smaller = "Smaller"
|
||||
show Same = "Same"
|
||||
show Unknown = "Unknown"
|
||||
|
||||
export
|
||||
Eq SizeChange where
|
||||
Smaller == Smaller = True
|
||||
Same == Same = True
|
||||
Unknown == Unknown = True
|
||||
_ == _ = False
|
||||
|
||||
export
|
||||
Ord SizeChange where
|
||||
compare Smaller Smaller = EQ
|
||||
compare Smaller _ = LT
|
||||
compare _ Smaller = GT
|
||||
compare Same Same = EQ
|
||||
compare Same _ = LT
|
||||
compare _ Same = GT
|
||||
compare Unknown Unknown = EQ
|
||||
|
||||
public export
|
||||
record SCCall where
|
||||
constructor MkSCCall
|
||||
|
Loading…
Reference in New Issue
Block a user