Open
Description
Synthesize
annotations are a bit annoying to read. The signal-to-noise ratio is pretty bad because most port names (like q
or cin
) are much shorter than PortName
and PortProduct
.
For example, this is from #654:
{-# ANN f
(Synthesize
{ t_name = "f"
, t_inputs = [ PortName "a"
, PortProduct "" [ PortName "b", PortName "c" ] ]
, t_output = PortProduct "res" [PortName "q"] }) #-}
But with -XOverloadedStrings
and -XOverloadedLists
and some instances, PortName
and PortProduct ""
can be elided like this:
{-# ANN f
(Synthesize
{ t_name = "f"
, t_inputs = [ "a", [ "b", "c" ] ]
, t_output = PortProduct "res" [ "q" ] }) #-}
The instances look like this:
import GHC.Exts
instance IsString PortName where
fromString = PortName
instance IsList PortName where
type Item PortName = PortName
fromList = PortProduct ""
toList = error "toList for PortName is not implemented"
Pros:
- Shorter annotation is both easier to read and easier to write
- Easy implementation
- Backwards compatible AFAIK, and can mix with other
PortName
s (seePortProduct "res" [ ... ]
above)
Cons:
- Can be confusing for someone not familiar with what's going on
- Two ways to write the same thing. Which one for documentation and tutorial?
toList
alwayserror
s. Maybe we can only haveIsString
and only avoid typing outPortName
for every port?