-
Notifications
You must be signed in to change notification settings - Fork 64
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
Plutarch Numeric hierarchy #160
base: staging
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good, very few missed hoists, etc., although I'm not really sure why you're removing the Num
instances?
Plutarch/Api/V1.hs
Outdated
@@ -290,8 +290,6 @@ deriving via | |||
|
|||
newtype PPOSIXTime (s :: S) | |||
= PPOSIXTime (Term s PInteger) | |||
deriving (PIntegral) via (PInteger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Plutarch/Builtin.hs
Outdated
@@ -228,15 +228,15 @@ instance PIsData PBool where | |||
(phoistAcyclic $ plam toBool) # pforgetData x | |||
where | |||
toBool :: Term s PData -> Term s PBool | |||
toBool d = pfstBuiltin # (pasConstr # d) #== 1 | |||
toBool d = pfstBuiltin # (pasConstr # d) #== pconstant 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
Plutarch/DataRepr.hs
Outdated
@@ -84,7 +95,7 @@ pindexDataList n = | |||
punsafeIndex @PBuiltinList @PData # ind | |||
where | |||
ind :: Term s PInteger | |||
ind = fromInteger $ natVal n | |||
ind = pconstant $ natVal n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
Plutarch/Integer.hs
Outdated
instance PEq PInteger where | ||
x #== y = punsafeBuiltin PLC.EqualsInteger # x # y | ||
|
||
instance POrd PInteger where | ||
x #<= y = punsafeBuiltin PLC.LessThanEqualsInteger # x # y | ||
x #< y = punsafeBuiltin PLC.LessThanInteger # x # y | ||
|
||
instance Num (Term s PInteger) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this instance?
Plutarch/Integer.hs
Outdated
ppowInteger :: PMultiplicativeGroup a => Term s a -> Term s PInteger -> Term s a | ||
ppowInteger a int = | ||
phoistAcyclic | ||
( plam $ \x i -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do-syntax please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't actually use do-syntax, because it breaks GHC 8.10.7...
Plutarch/Integer.hs
Outdated
forall s a. | ||
(PMultiplicativeMonoid a) => | ||
Term s (a :--> PInteger :--> a) | ||
pexpBySquaring = pfix #$ plam f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't hoisted.
Plutarch/List.hs
Outdated
go = (pfix #$ plam $ \self ls n -> pelimList (\_ xs -> self # xs # n + 1) n ls) | ||
in go # xs # 0 | ||
go = (pfix #$ plam $ \self ls n -> pelimList (\_ xs -> self # xs # n #+ pone) n ls) | ||
in go # xs # pzero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
Plutarch/Natural.hs
Outdated
|
||
-- We made sure that PInteger >= zero as it goes from PNatural. | ||
pnatFromIntUnsafe :: Term s PInteger -> Term s PNatural | ||
pnatFromIntUnsafe = pcon . PNatural |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it should be punsafe*
.
Plutarch/Natural.hs
Outdated
|
||
instance PIsData PNatural where | ||
pfromData x = | ||
phoistAcyclic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use pfromData
for integers here without all this complex logic. The argument passed to this function is PAsData PNatural
, so we already know it's correct. No need to check anything.
Plutarch/Natural.hs
Outdated
PNothing -> perror | ||
) | ||
# x | ||
pdata x = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the unnecessary lambda here either.
I'm not sure about And I must admit, using |
I think it's good to have the new classes, but I don't see why |
OK, I'll return them back |
I'm trying to get this ready for Plutarch 1.2, as part of |
@TotallyNotChase is this ready? |
No description provided.