-
Notifications
You must be signed in to change notification settings - Fork 483
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
CIP-0138 Builtin Array #6727
base: master
Are you sure you want to change the base?
CIP-0138 Builtin Array #6727
Changes from all commits
a3cca3f
763a261
6eb76ee
2ac9dba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -698,6 +698,36 @@ | |
"type": "constant_cost" | ||
} | ||
}, | ||
"lengthArray" : { | ||
"cpu": { | ||
"arguments": 99999999999999, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temporary value (stub) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I was adding builtins, I was avoiding doing any of this, but maybe that was wrong, dunno. @kwxm should we add this stuff when adding a new builtin before costing is done? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that in order to get the code to compile you have to add something here once you've added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, doing it first time it isn't 100% clear where to draw the line, so I followed the compiler and it wanted me to fix JSON as there is TH which reads it and fails to compile if the section is missing. |
||
"type": "constant_cost" | ||
}, | ||
"memory": { | ||
"arguments": 99999999999999, | ||
"type": "constant_cost" | ||
} | ||
}, | ||
"listToArray": { | ||
"cpu": { | ||
"arguments": 99999999999999, | ||
"type": "constant_cost" | ||
}, | ||
"memory": { | ||
"arguments": 99999999999999, | ||
"type": "constant_cost" | ||
} | ||
}, | ||
"indexArray": { | ||
"cpu": { | ||
"arguments": 99999999999999, | ||
"type": "constant_cost" | ||
}, | ||
"memory": { | ||
"arguments": 99999999999999, | ||
"type": "constant_cost" | ||
} | ||
}, | ||
"quotientInteger": { | ||
"cpu": { | ||
"arguments": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
module Data.Vector.Orphans () where | ||
|
||
import Data.Hashable (Hashable (hashWithSalt)) | ||
import Data.Vector.Strict qualified as Strict | ||
import Flat (Flat (..)) | ||
import Flat.Instances.Vector () | ||
|
||
instance (Hashable a) => Hashable (Strict.Vector a) where | ||
hashWithSalt = Strict.foldl' hashWithSalt | ||
|
||
instance (Flat a) => Flat (Strict.Vector a) where | ||
size = size . Strict.toLazy -- Strict to Lazy is O(1) | ||
encode = encode . Strict.toLazy | ||
decode = Strict.fromLazy <$> decode -- Strict from Lazy is O(1) | ||
Unisay marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Dummy values
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.
@kwxm is this what should be done here before costing? Particularly given that
listToArray
isn't gonna be constant-cost.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.
Good question. I think that this doesn't really matter as long as you remember to fix it. The only time this gets used is when you run
generate-cost-model
, which uses this information to fill in the memory function in the JSON version of the cost model, so it has to be correct before you generate the final form of the cost model.