-
Notifications
You must be signed in to change notification settings - Fork 0
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
Compile Prim nodes to Hugr DFG #34
Conversation
brat/examples/vec_map.brat
Outdated
@@ -0,0 +1,15 @@ | |||
ext "to_float" to_float(i :: Int) -> Float |
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.
maybe this file would be better called "mono_vec_map.brat" (or monomorphic...)
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.
Also "list" rather than "vec"
brat/Brat/Compile/Hugr.hs
Outdated
ins <- addNodeWithInputs ("Inputs" ++ n) (OpIn (InputNode dfg_id inputTys)) [] inputTys | ||
outs <- addNodeWithInputs n (OpCustom (CustomOp dfg_id ext op box_sig [])) ins outputTys | ||
addNodeWithInputs ("Outputs" ++ n) (OpOut (OutputNode dfg_id outputTys)) outs [] >>= \case | ||
[] -> pure () |
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.
I think the test that there's no outputs seems superfluous (+ haskell will emit a warning about the incomplete pattern match)
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.
Well, not superfluous exactly, but I don't think we need to be quite so defensive
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.
Yeah, this is pretty much the same thing as your other comment - it does seem dang hard to write what are basically assertions, so instead we just drop the value and lose a (small in terms of source code) check that things are working the way we expect. And the warnings against incomplete matches (there are loads in this file!) just require us to write much longer/more verbose code to turn one kind of runtime failure into another...
What's the right thing to do here? Can we instance MonadFail Compile
and handle all these incomplete matches in our own code (which might still just error
but at least it'd silence the warnings)? For another PR, I mean - I've shortened/silenced these here for the time being.
brat/Brat/Compile/Hugr.hs
Outdated
addNodeWithInputs ("Outputs" ++ n) (OpOut (OutputNode dfg_id outputTys)) outs [] >>= \case | ||
[] -> pure () | ||
case p of | ||
(Port loadConst 0) -> pure $ default_edges loadConst |
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.
Just for the sake of the GHC warning, we should add a catch all that throws an error
* Driveby cleanups of some misnamed `examples/` * Add monomorphic test so it compiles+validaties rather than having any type erasure issues (#18)
examples/
files where I looked to put this seemed misnamed, so some driveby cleanups