You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More a suggestion than an issue: we recently implemented packing of sum(-of-product) types in Clash by separating the process of packing fields from packing the constructor. See:
Perhaps/hopefully these ideas can be easily converted to blarney. Although you would then also need first-class patterns (as in e.g. http://hackage.haskell.org/package/first-class-patterns) for sum-types to be useful in EDSLs (otherwise you can't "eliminate" sum types). However, with GHC 8.8 you'll get source plugins, by which perhaps you can convert Haskell case-statements to first-class patterns.
The text was updated successfully, but these errors were encountered:
Many thanks for the links. Nice to see that packing a sum type works with generic deriving, but to be useful I think we'd also need unpack, which is much harder. For example, makeReg :: Bits a => Module (Reg a) in Blarney needs pack (so that the typed value can be fed into a verilog register) and also unpack (so that the output of the verilog register can be viewed in its typed form).
Like you say, some heavier machinery seems to be required. Personally, I'm not sure it's worth it.
Somewhat related, we do have a couple of small libraries for pattern matching on bit strings: Blarney.BitScan and Blarney.BitPat.
More a suggestion than an issue: we recently implemented packing of sum(-of-product) types in Clash by separating the process of packing fields from packing the constructor. See:
The
default
methods for thePack
class: https://github.com/clash-lang/clash-compiler/blob/6422262599ebf53b4bf97d44a5b063c92d3ff81b/clash-prelude/src/Clash/Class/BitPack.hs#L73-L131The Generic
GBitpack
class: https://github.com/clash-lang/clash-compiler/blob/6422262599ebf53b4bf97d44a5b063c92d3ff81b/clash-prelude/src/Clash/Class/BitPack.hs#L273-L300The generic instances for sum types: https://github.com/clash-lang/clash-compiler/blob/6422262599ebf53b4bf97d44a5b063c92d3ff81b/clash-prelude/src/Clash/Class/BitPack.hs#L309-L338
Perhaps/hopefully these ideas can be easily converted to
blarney
. Although you would then also need first-class patterns (as in e.g. http://hackage.haskell.org/package/first-class-patterns) for sum-types to be useful in EDSLs (otherwise you can't "eliminate" sum types). However, with GHC 8.8 you'll get source plugins, by which perhaps you can convert Haskell case-statements to first-class patterns.The text was updated successfully, but these errors were encountered: