News for hackers. Stuff that matters.
Re:nMigen – A refreshed Python toolbox for building complex ... by a1369209993 on Saturday October 23, 2021 @09:59PM (#28974235)
IIUC, this is actually a general deficiency in the type system for variable-width tuples. Consider:

  f1 :: (Bit,()) -> Int
  f1 (0,()) = 3
  f1 (1,()) = 3
  -- f1 (0,undefined) is undefined
  f2 :: (Bit,(Bit,())) -> Int
  -- and so on. Conversely
  g2 :: Bit -> Bit -> Int
  g1 :: Bit -> Int
  g0 :: Int
  -- doesn't have this problem but also doesn't work well for busses.
  -- The 'obvious' approach
  h3 :: (Bit,Bit,Bit) -> Int
  h2 :: (Bit,Bit) -> Int
  h1 :: (Bit) -> Int
  h0 :: () -> Int
  -- doesn't work generically; (Bit) isn't a tuple at all,
  -- and n-element tuples are totally unrelated to m(!=n)-element tuples
  -- (they're literally declared as:
  data (a,b) = (a,b)
  data (a,b,c) = (a,b,c)
  -- in module GHC.Tuple)

You can actually fix this by (ab)using types of kind `TYPE 'UnliftedRep` and unboxed tuples (type `(# Car, Cdr #)`, value `(# b7, b6543210 #)`), it's just generally not worth the effort.

There are no comments on this comment yet.