Skip to content
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

inlineCleanup introduces free variables #1337

Closed
martijnbastiaan opened this issue May 18, 2020 · 3 comments · Fixed by #1342
Closed

inlineCleanup introduces free variables #1337

martijnbastiaan opened this issue May 18, 2020 · 3 comments · Fixed by #1342
Assignees
Labels

Comments

@martijnbastiaan
Copy link
Member

martijnbastiaan commented May 18, 2020

Updated issue report 19 May 2020:

If inlineCleanup is given an expression of the following form:

let
  result = a

  a = b
  b = c
  c = a b
in
  result

Depending on the actual expressions that the various binders represent, it will determine result is a binding that should be "kept", while all others should be inlined. inlineBndrsCleanup will try to do this, but it currently fails to handle this case correctly. It will yield:

let
  result = b
  b = a b
in 
  result

i.e., it will introduce a free variable!


Original issue report 18 May 2020:

Compiling the following:

{-# LANGUAGE GADTs               #-}
{-# LANGUAGE NoImplicitPrelude   #-}
{-# LANGUAGE RecordWildCards     #-}

module Test where

import Clash.Prelude

type Lanes = 2

data SigFn a b = SigFn { runSigFn :: SigType a -> SigType b }

class Sig a where
  type SigType a

instance Sig Bit where
  type SigType Bit = Signal System Bit

instance Sig a => Sig (Vec n a) where
  type SigType (Vec n a) = Vec n (SigType a)

instance (Sig a, Sig b) => Sig (a, b) where
  type SigType (a, b) = (SigType a, SigType b)

singletonSigFn :: SigFn a (Vec 1 a)
singletonSigFn = SigFn singleton

headSigFn :: SigFn (Vec 1 a) a
headSigFn = SigFn head

defSigFn :: Default (SigType t) => SigFn s t
defSigFn = SigFn (const def)

(>>>) :: SigFn a b -> SigFn b c -> SigFn a c
SigFn f >>> SigFn g = SigFn (g . f)

(<=>) :: SigFn a b -> SigFn c d -> SigFn (a, c) (b, d)
SigFn f <=> SigFn g = SigFn (\(x, y) -> (f x, g y))

splitSigFn :: KnownNat n => SigFn (Vec (n + m) a) (Vec n a, Vec m a)
splitSigFn = SigFn splitAtI

catSigFn :: SigFn (Vec n a, Vec m a) (Vec (n + m) a)
catSigFn = SigFn (\(x, y) -> x ++ y)

data BitLayout t where
  BitLayout :: forall bitCount t
            .  ( KnownNat bitCount )
            => { bitCount :: SNat bitCount
               , inFn :: SigFn t (Vec bitCount Bit)
               , outFn :: SigFn (Vec bitCount Bit) t
               }
            -> BitLayout t

unitLayout :: BitLayout Bit
unitLayout = BitLayout SNat singletonSigFn headSigFn

voidLayout :: forall t . Default (SigType t) => BitLayout t
voidLayout = BitLayout d0 defSigFn defSigFn

catLayout
  :: forall n m s
  .  ( KnownNat n
     , KnownNat m
     , 1 <= n )
  => BitLayout (Vec n s)
  -> BitLayout (Vec m s)
  -> BitLayout (Vec (n + m) s)
catLayout (BitLayout aBitCount aInFn aOutFn) (BitLayout bBitCount bInFn bOutFn) = let
  inFn = splitSigFn >>> (aInFn <=> bInFn) >>> catSigFn
  outFn = splitSigFn >>> (aOutFn <=> bOutFn) >>> catSigFn
  in BitLayout SNat inFn outFn

vecLayout
  :: forall n n' t
  .  ( n' ~ (n - 1)
     , 1 <= n
     , KnownNat n
     , KnownNat n' )
  => Vec n (BitLayout t)
  -> BitLayout (Vec n t)
vecLayout (BitLayout{..} :> others) = let
  headLayout = BitLayout SNat (headSigFn >>> inFn) (outFn >>> singletonSigFn)
  in case others of
       Nil -> headLayout
       _ -> headLayout `catLayout` vecLayout @n' others

layout :: BitLayout (Vec Lanes Bit)
layout = mkPos (0 :: Index (Lanes + 1))

mkPos
  :: forall rp
  .  ( KnownNat rp
     , 1 <= rp
     )
  => Index (rp + 1)
  -> BitLayout (Vec rp Bit)
mkPos n = let
  lanes = map (\i -> if i < n
                     then unitLayout
                     else voidLayout) $ iterateI succ 0
  in vecLayout lanes

runBitLayout
  :: Default (SigType t)
  => BitLayout t
  -> SigType t
  -> SigType t
runBitLayout BitLayout{..} = runSigFn ( inFn >>> outFn )

topEntity :: Vec Lanes (Signal System Bit) -> Vec Lanes (Signal System Bit)
topEntity = runBitLayout layout

with

cabal new-run clash -- Test.hs --vhdl -fclash-debug DebugSilent -fclash-compile-ultra

yields:

<no location info>: error:
    Clash error call:
    Clash.Rewrite.Util(232): Error when applying rewrite inlineCleanup to:
    letrec
      result[31996] :: Test.SigType[8214565720323817080]
                         (Clash.Sized.Vector.Vec[8214565720323788085]
                            2
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31995][LocalId] of
          GHC.Types.False[3891110078048108556]  ->
            result[31849][LocalId]
          GHC.Types.True[3891110078048108589]  ->
            result[31994][LocalId]
      c$case_scrut[31995] :: GHC.Types.Bool[3674937295934324744]
      = Clash.Sized.Internal.Index.lt#
          @(GHC.TypeNats.+[3674937295934325068] 2 1)
          elH0[279][LocalId]
          (Clash.Sized.Internal.Index.fromInteger# @3 3 0)
      result[31994] :: Test.SigType[8214565720323817080]
                         (Clash.Sized.Vector.Vec[8214565720323788085]
                            2
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31848][LocalId] of
          GHC.Types.False[3891110078048108556]  ->
            result[31918][LocalId]
          GHC.Types.True[3891110078048108589]  ->
            result[31985][LocalId]
      result[31985] :: Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         (Test.SigType[8214565720323817080]
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          @1
          _CO_
          <prefixName>"unitLayout"
          <prefixName>"headSigFn"
          elH0[11213][LocalId]
          c$app_arg[31984][LocalId]
      c$app_arg[31984] :: Clash.Sized.Vector.Vec[8214565720323788085]
                            1
                            (Test.SigType[8214565720323817080]
                               Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @1
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          @0
          _CO_
          <prefixName>"unitLayout"
          <prefixName>"headSigFn"
          elH0[15333][LocalId]
          (Clash.Sized.Vector.Nil[8214565720323788089] @0
             @(Test.SigType[8214565720323817080]
                 Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
             _CO_)
      result[31918] :: Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         (Test.SigType[8214565720323817080]
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          @1
          _CO_
          <prefixName>"unitLayout"
          <prefixName>"headSigFn"
          elH0[11013][LocalId]
          (Clash.Sized.Vector.Cons[8214565720323788088] @1
             @(Test.SigType[8214565720323817080]
                 Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
             @0
             _CO_
             <prefixName>"layout_$svoidLayout"
             <prefixName>"layout1"
             <prefixName>"layout2"
             <prefixName>"layout3"
             Clash.Sized.Internal.BitVector.low
             (Clash.Sized.Vector.Nil[8214565720323788089] @0
                @(Test.SigType[8214565720323817080]
                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                _CO_))
      result[31849] :: Test.SigType[8214565720323817080]
                         (Clash.Sized.Vector.Vec[8214565720323788085]
                            2
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31848][LocalId] of
          GHC.Types.False[3891110078048108556]  ->
            Clash.Sized.Vector.Cons[8214565720323788088] @2
              @(Test.SigType[8214565720323817080]
                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              @1
              _CO_
              <prefixName>"layout_$svoidLayout"
              <prefixName>"layout1"
              <prefixName>"layout2"
              <prefixName>"layout3"
              Clash.Sized.Internal.BitVector.low
              (Clash.Sized.Vector.Cons[8214565720323788088] @1
                 @(Test.SigType[8214565720323817080]
                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                 @0
                 _CO_
                 <prefixName>"layout_$svoidLayout"
                 <prefixName>"layout1"
                 <prefixName>"layout2"
                 <prefixName>"layout3"
                 Clash.Sized.Internal.BitVector.low
                 (Clash.Sized.Vector.Nil[8214565720323788089] @0
                    @(Test.SigType[8214565720323817080]
                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                    _CO_))
          GHC.Types.True[3891110078048108589]  ->
            c$case_alt[31847][LocalId]
      c$case_scrut[31848] :: GHC.Types.Bool[3674937295934324744]
      = Clash.Sized.Internal.Index.lt#
          @(GHC.TypeNats.+[3674937295934325068] 2 1)
          elA1[439][LocalId]
          (Clash.Sized.Internal.Index.fromInteger# @3 3 0)
      c$case_alt[31847] :: Clash.Sized.Vector.Vec[8214565720323788085]
                             2
                             (Test.SigType[8214565720323817080]
                                Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          @1
          _CO_
          <prefixName>"layout_$svoidLayout"
          <prefixName>"layout1"
          <prefixName>"layout2"
          <prefixName>"layout3"
          Clash.Sized.Internal.BitVector.low
          c$app_arg[31839][LocalId]
      c$app_arg[31839] :: Clash.Sized.Vector.Vec[8214565720323788085]
                            1
                            (Test.SigType[8214565720323817080]
                               Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @1
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          @0
          _CO_
          <prefixName>"unitLayout"
          <prefixName>"headSigFn"
          elH0[14309][LocalId]
          (Clash.Sized.Vector.Nil[8214565720323788089] @0
             @(Test.SigType[8214565720323817080]
                 Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
             _CO_)
      elH0[15333] :: Test.SigType[8214565720323817080]
                       Clash.Sized.Internal.BitVector.Bit[8214565720323788076]
      = case y[6989586621679044938][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[15328]
            (_co_[15331] :: GHC.Prim.~#[3674937295934324842]
                              GHC.Types.Nat[3674937295934325064]
                              GHC.Types.Nat[3674937295934325064]
                              1
                              (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[15330] :: Test.SigType[8214565720323817080]
                              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              (rest[15329] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                0
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            el[15330][LocalId]
      y[6989586621679044938] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31986][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$wild[31990] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                1
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$sel[31992] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 1
                                 (Test.SigType[8214565720323817080]
                                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31992][LocalId]
      elH0[14309] :: Test.SigType[8214565720323817080]
                       Clash.Sized.Internal.BitVector.Bit[8214565720323788076]
      = case y[6989586621679044887][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[14304]
            (_co_[14307] :: GHC.Prim.~#[3674937295934324842]
                              GHC.Types.Nat[3674937295934325064]
                              GHC.Types.Nat[3674937295934325064]
                              1
                              (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[14306] :: Test.SigType[8214565720323817080]
                              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              (rest[14305] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                0
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            el[14306][LocalId]
      y[6989586621679044887] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31840][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$wild[31844] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                0
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$sel[31846] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 1
                                 (Test.SigType[8214565720323817080]
                                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31846][LocalId]
      c$case_scrut[31840] :: GHC.Tuple.(,)[3746994889972252676]
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  0
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
      = Clash.Sized.Vector.splitAt @0 @1
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          (Clash.Promoted.Nat.SNat[8214565720323787967] @0
             <prefixName>"layout_$svoidLayout"
             <prefixName>"$s$WBitLayout1"
             0)
          c$app_arg[31950][LocalId]
      elH0[11213] :: Test.SigType[8214565720323817080]
                       Clash.Sized.Internal.BitVector.Bit[8214565720323788076]
      = case x[6989586621679044936][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[11208]
            (_co_[11211] :: GHC.Prim.~#[3674937295934324842]
                              GHC.Types.Nat[3674937295934325064]
                              GHC.Types.Nat[3674937295934325064]
                              1
                              (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[11210] :: Test.SigType[8214565720323817080]
                              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              (rest[11209] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                0
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            el[11210][LocalId]
      x[6989586621679044936] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31986][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$sel[31989] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$wild[31988] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31989][LocalId]
      c$case_scrut[31986] :: GHC.Tuple.(,)[3746994889972252676]
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
      = Clash.Sized.Vector.splitAt @1 @1
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          (Clash.Promoted.Nat.SNat[8214565720323787967] @1
             <prefixName>"unitLayout"
             <prefixName>"$s$WBitLayout3"
             1)
          result[31951][LocalId]
      result[31951] :: Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         (Test.SigType[8214565720323817080]
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          @1
          _CO_
          <prefixName>"unitLayout"
          <prefixName>"singletonSigFn"
          <prefixName>"singletonSigFn1"
          elH0[5893][LocalId]
          c$app_arg[31950][LocalId]
      c$app_arg[31950] :: Clash.Sized.Vector.Vec[8214565720323788085]
                            1
                            (Test.SigType[8214565720323817080]
                               Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = <prefixName>"unitLayout"
      <prefixName>"singletonSigFn"
      <prefixName>"singletonSigFn1"
      Clash.Sized.Vector.Cons[8214565720323788088] @1
        @(Test.SigType[8214565720323817080]
            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
        @0
        _CO_
        elH0[4875][LocalId]
        (Clash.Sized.Vector.Nil[8214565720323788089] @0
           @(Test.SigType[8214565720323817080]
               Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
           _CO_)
      elH0[11013] :: Test.SigType[8214565720323817080]
                       Clash.Sized.Internal.BitVector.Bit[8214565720323788076]
      = case x[6989586621679044914][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[11008]
            (_co_[11011] :: GHC.Prim.~#[3674937295934324842]
                              GHC.Types.Nat[3674937295934325064]
                              GHC.Types.Nat[3674937295934325064]
                              1
                              (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[11010] :: Test.SigType[8214565720323817080]
                              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              (rest[11009] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                0
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            el[11010][LocalId]
      x[6989586621679044914] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31919][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$sel[31922] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$wild[31921] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                  0
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31922][LocalId]
      c$case_scrut[31919] :: GHC.Tuple.(,)[3746994889972252676]
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  0
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
      = Clash.Sized.Vector.splitAt @1 @0
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          (Clash.Promoted.Nat.SNat[8214565720323787967] @1
             <prefixName>"unitLayout"
             <prefixName>"$s$WBitLayout3"
             1)
          c$case_alt[31905][LocalId]
      c$case_alt[31905] :: Clash.Sized.Vector.Vec[8214565720323788085]
                             1
                             (Test.SigType[8214565720323817080]
                                Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = <prefixName>"unitLayout"
      <prefixName>"singletonSigFn"
      <prefixName>"singletonSigFn1"
      Clash.Sized.Vector.Cons[8214565720323788088] @1
        @(Test.SigType[8214565720323817080]
            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
        @0
        _CO_
        elH0[5893][LocalId]
        (Clash.Sized.Vector.Nil[8214565720323788089] @0
           @(Test.SigType[8214565720323817080]
               Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
           _CO_)
      elH0[5893] :: Test.SigType[8214565720323817080]
                      Clash.Sized.Internal.BitVector.Bit[8214565720323788076]
      = case x[6989586621679044907][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[5888]
            (_co_[5891] :: GHC.Prim.~#[3674937295934324842]
                             GHC.Types.Nat[3674937295934325064]
                             GHC.Types.Nat[3674937295934325064]
                             1
                             (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[5890] :: Test.SigType[8214565720323817080]
                             Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              (rest[5889] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               0
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            el[5890][LocalId]
      x[6989586621679044907] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31818][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$sel[31901] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$wild[31900] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                  (GHC.TypeNats.-[3674937295934325076] 2 1)
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31901][LocalId]
      elH0[4875] :: Test.SigType[8214565720323817080]
                      Clash.Sized.Internal.BitVector.Bit[8214565720323788076]
      = case y[6989586621679044822][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[4870]
            (_co_[4873] :: GHC.Prim.~#[3674937295934324842]
                             GHC.Types.Nat[3674937295934325064]
                             GHC.Types.Nat[3674937295934325064]
                             1
                             (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[4872] :: Test.SigType[8214565720323817080]
                             Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              (rest[4871] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               0
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            el[4872][LocalId]
      y[6989586621679044822] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     (GHC.TypeNats.-[3674937295934325076] 2 1)
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31818][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$wild[31822] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                1
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$sel[31824] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 (GHC.TypeNats.-[3674937295934325076] 2 1)
                                 (Test.SigType[8214565720323817080]
                                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31824][LocalId]
      c$case_scrut[31818] :: GHC.Tuple.(,)[3746994889972252676]
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  (GHC.TypeNats.-[3674937295934325076] 2 1)
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
      = Clash.Sized.Vector.splitAt @1
          @(GHC.TypeNats.-[3674937295934325076] 2 1)
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          (Clash.Promoted.Nat.SNat[8214565720323787967] @1
             1)
          c$arg[17344][LocalId]
      elA1[439] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                     (GHC.TypeNats.+[3674937295934325068] 2 1)
      = <prefixName>"topEntity1_eta"
      case restL0[404][LocalId] of
        Clash.Sized.Vector.Cons[8214565720323788088] m[471]
          (_co_[475] :: GHC.Prim.~#[3674937295934324842]
                          GHC.Types.Nat[3674937295934325064]
                          GHC.Types.Nat[3674937295934325064]
                          1
                          (GHC.TypeNats.+[3674937295934325068] 0 1))
            (el[530] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                          (GHC.TypeNats.+[3674937295934325068] 2 1))
            (rest[531] :: Clash.Sized.Vector.Vec[8214565720323788085]
                            0
                            (Clash.Sized.Internal.Index.Index[8214565720323788078]
                               (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
          el[530][LocalId]
      elL1[15] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                    (GHC.TypeNats.+[3674937295934325068] 2 1)
      = case result[31719][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[10]
            (_co_[13] :: GHC.Prim.~#[3674937295934324842]
                           GHC.Types.Nat[3674937295934325064]
                           GHC.Types.Nat[3674937295934325064]
                           2
                           (GHC.TypeNats.+[3674937295934325068] 1 1))
              (el[12] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                           (GHC.TypeNats.+[3674937295934325068] 2 1))
              (rest[11] :: Clash.Sized.Vector.Vec[8214565720323788085]
                             1
                             (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
            el[12][LocalId]
      result[31719] :: Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         (Clash.Sized.Internal.Index.Index[8214565720323788078]
                            (GHC.TypeNats.+[3674937295934325068] 2 1))
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Clash.Sized.Internal.Index.Index[8214565720323788078]
              (GHC.TypeNats.+[3674937295934325068] 2 1))
          @1
          _CO_
          c$rest_app_arg[31716][LocalId]
          c$rest_app_arg[31718][LocalId]
      c$rest_app_arg[31718] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 1
                                 (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                    (GHC.TypeNats.+[3674937295934325068] 2 1))
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @1
          @(Clash.Sized.Internal.Index.Index[8214565720323788078]
              (GHC.TypeNats.+[3674937295934325068] 2 1))
          @0
          _CO_
          c$rest_app_arg[31717][LocalId]
          (Clash.Sized.Vector.Nil[8214565720323788089] @0
             @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                 (GHC.TypeNats.+[3674937295934325068] 2 1))
             _CO_)
      c$rest_app_arg[31717] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                 (GHC.TypeNats.+[3674937295934325068] 2 1)
      = <prefixName>"$s$fEnumIndex_$csucc"
          <prefixName>"$s$fEnumIndex_$csucc_lvl11"
          Clash.Sized.Internal.Index.+#
          @(GHC.TypeNats.+[3674937295934325068] 2 1)
          (Clash.Transformations.removedArg
             @GHC.Natural.Natural[3674937295934324786])
          elA1[33][LocalId]
          (Clash.Sized.Internal.Index.fromInteger#
             @(GHC.TypeNats.+[3674937295934325068] 2 1)
             3
             1)
      elA1[33] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                    (GHC.TypeNats.+[3674937295934325068] 2 1)
      = case restA0[26][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[28]
            (_co_[49] :: GHC.Prim.~#[3674937295934324842]
                           GHC.Types.Nat[3674937295934325064]
                           GHC.Types.Nat[3674937295934325064]
                           1
                           (GHC.TypeNats.+[3674937295934325068] 0 1))
              (el[30] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                           (GHC.TypeNats.+[3674937295934325068] 2 1))
              (rest[29] :: Clash.Sized.Vector.Vec[8214565720323788085]
                             0
                             (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
            el[30][LocalId]
      restA0[26] :: Clash.Sized.Vector.Vec[8214565720323788085]
                      1
                      (Clash.Sized.Internal.Index.Index[8214565720323788078]
                         (GHC.TypeNats.+[3674937295934325068] 2 1))
      = Clash.Sized.Vector.lazyV @1
          @(Clash.Sized.Internal.Index.Index[8214565720323788078]
              (GHC.TypeNats.+[3674937295934325068] 2 1))
          (Clash.Transformations.removedArg
             @GHC.Natural.Natural[3674937295934324786])
          restL0[404][LocalId]
      restL0[404] :: Clash.Sized.Vector.Vec[8214565720323788085]
                       1
                       (Clash.Sized.Internal.Index.Index[8214565720323788078]
                          (GHC.TypeNats.+[3674937295934325068] 2 1))
      = case <prefixName>"layout"
          <prefixName>"layout_$smkPos"
          result[31733][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[400]
            (_co_[403] :: GHC.Prim.~#[3674937295934324842]
                            GHC.Types.Nat[3674937295934325064]
                            GHC.Types.Nat[3674937295934325064]
                            2
                            (GHC.TypeNats.+[3674937295934325068] 1 1))
              (el[402] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                            (GHC.TypeNats.+[3674937295934325068] 2 1))
              (rest[401] :: Clash.Sized.Vector.Vec[8214565720323788085]
                              1
                              (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                 (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
            rest[401][LocalId]
      c$rest_app_arg[31716] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                 (GHC.TypeNats.+[3674937295934325068] 2 1)
      = <prefixName>"$s$fEnumIndex_$csucc"
          <prefixName>"$s$fEnumIndex_$csucc_lvl11"
          Clash.Sized.Internal.Index.+#
          @(GHC.TypeNats.+[3674937295934325068] 2 1)
          (Clash.Transformations.removedArg
             @GHC.Natural.Natural[3674937295934324786])
          elH0[279][LocalId]
          (Clash.Sized.Internal.Index.fromInteger#
             @(GHC.TypeNats.+[3674937295934325068] 2 1)
             3
             1)
      elH0[279] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                     (GHC.TypeNats.+[3674937295934325068] 2 1)
      = case <prefixName>"layout"
          <prefixName>"layout_$smkPos"
          result[31733][LocalId] of
          Clash.Sized.Vector.Cons[8214565720323788088] m[274]
            (_co_[277] :: GHC.Prim.~#[3674937295934324842]
                            GHC.Types.Nat[3674937295934325064]
                            GHC.Types.Nat[3674937295934325064]
                            2
                            (GHC.TypeNats.+[3674937295934325068] 1 1))
              (el[276] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                            (GHC.TypeNats.+[3674937295934325068] 2 1))
              (rest[275] :: Clash.Sized.Vector.Vec[8214565720323788085]
                              1
                              (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                 (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
            el[276][LocalId]
      result[31733] :: Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         (Clash.Sized.Internal.Index.Index[8214565720323788078]
                            (GHC.TypeNats.+[3674937295934325068] 2 1))
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Clash.Sized.Internal.Index.Index[8214565720323788078]
              (GHC.TypeNats.+[3674937295934325068] 2 1))
          @1
          _CO_
          (Clash.Sized.Internal.Index.fromInteger#
             @(GHC.TypeNats.+[3674937295934325068] 2 1)
             3
             0)
          c$xs_app_arg[31732][LocalId]
      c$xs_app_arg[31732] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                  (GHC.TypeNats.+[3674937295934325068] 2 1))
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @1
          @(Clash.Sized.Internal.Index.Index[8214565720323788078]
              (GHC.TypeNats.+[3674937295934325068] 2 1))
          @0
          _CO_
          elL1[15][LocalId]
          (Clash.Sized.Vector.Nil[8214565720323788089] @0
             @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                 (GHC.TypeNats.+[3674937295934325068] 2 1))
             _CO_)
    in result[31996][LocalId]
    Result:
    letrec
      result[31996] :: Test.SigType[8214565720323817080]
                         (Clash.Sized.Vector.Vec[8214565720323788085]
                            2
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case Clash.Sized.Internal.Index.lt#
               @(GHC.TypeNats.+[3674937295934325068] 2 1)
               (case <prefixName>"layout"
                  <prefixName>"layout_$smkPos"
                  result[31733][LocalId] of
                  Clash.Sized.Vector.Cons[8214565720323788088] m[274]
                    (_co_[277] :: GHC.Prim.~#[3674937295934324842]
                                    GHC.Types.Nat[3674937295934325064]
                                    GHC.Types.Nat[3674937295934325064]
                                    2
                                    (GHC.TypeNats.+[3674937295934325068] 1 1))
                      (el[276] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                    (GHC.TypeNats.+[3674937295934325068] 2 1))
                      (rest[275] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                      1
                                      (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                         (GHC.TypeNats.+[3674937295934325068]
                                            2
                                            1))) ->
                    el[276][LocalId])
               (Clash.Sized.Internal.Index.fromInteger# @3 3
                  0) of
          GHC.Types.False[3891110078048108556]  ->
            result[31849][LocalId]
          GHC.Types.True[3891110078048108589]  ->
            result[31994][LocalId]
      result[31994] :: Test.SigType[8214565720323817080]
                         (Clash.Sized.Vector.Vec[8214565720323788085]
                            2
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31848][LocalId] of
          GHC.Types.False[3891110078048108556]  ->
            Clash.Sized.Vector.Cons[8214565720323788088] @2
              @(Test.SigType[8214565720323817080]
                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              @1
              _CO_
              <prefixName>"unitLayout"
              <prefixName>"headSigFn"
              (case x[6989586621679044914][LocalId] of
                 Clash.Sized.Vector.Cons[8214565720323788088] m[11008]
                   (_co_[11011] :: GHC.Prim.~#[3674937295934324842]
                                     GHC.Types.Nat[3674937295934325064]
                                     GHC.Types.Nat[3674937295934325064]
                                     1
                                     (GHC.TypeNats.+[3674937295934325068] 0 1))
                     (el[11010] :: Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                     (rest[11009] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                       0
                                       (Test.SigType[8214565720323817080]
                                          Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                   el[11010][LocalId])
              (Clash.Sized.Vector.Cons[8214565720323788088] @1
                 @(Test.SigType[8214565720323817080]
                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                 @0
                 _CO_
                 <prefixName>"layout_$svoidLayout"
                 <prefixName>"layout1"
                 <prefixName>"layout2"
                 <prefixName>"layout3"
                 Clash.Sized.Internal.BitVector.low
                 (Clash.Sized.Vector.Nil[8214565720323788089] @0
                    @(Test.SigType[8214565720323817080]
                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                    _CO_))
          GHC.Types.True[3891110078048108589]  ->
            Clash.Sized.Vector.Cons[8214565720323788088] @2
              @(Test.SigType[8214565720323817080]
                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              @1
              _CO_
              <prefixName>"unitLayout"
              <prefixName>"headSigFn"
              (case x[6989586621679044936][LocalId] of
                 Clash.Sized.Vector.Cons[8214565720323788088] m[11208]
                   (_co_[11211] :: GHC.Prim.~#[3674937295934324842]
                                     GHC.Types.Nat[3674937295934325064]
                                     GHC.Types.Nat[3674937295934325064]
                                     1
                                     (GHC.TypeNats.+[3674937295934325068] 0 1))
                     (el[11210] :: Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                     (rest[11209] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                       0
                                       (Test.SigType[8214565720323817080]
                                          Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                   el[11210][LocalId])
              (Clash.Sized.Vector.Cons[8214565720323788088] @1
                 @(Test.SigType[8214565720323817080]
                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                 @0
                 _CO_
                 <prefixName>"unitLayout"
                 <prefixName>"headSigFn"
                 (case y[6989586621679044938][LocalId] of
                    Clash.Sized.Vector.Cons[8214565720323788088] m[15328]
                      (_co_[15331] :: GHC.Prim.~#[3674937295934324842]
                                        GHC.Types.Nat[3674937295934325064]
                                        GHC.Types.Nat[3674937295934325064]
                                        1
                                        (GHC.TypeNats.+[3674937295934325068] 0 1))
                        (el[15330] :: Test.SigType[8214565720323817080]
                                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                        (rest[15329] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                          0
                                          (Test.SigType[8214565720323817080]
                                             Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                      el[15330][LocalId])
                 (Clash.Sized.Vector.Nil[8214565720323788089] @0
                    @(Test.SigType[8214565720323817080]
                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                    _CO_))
      result[31849] :: Test.SigType[8214565720323817080]
                         (Clash.Sized.Vector.Vec[8214565720323788085]
                            2
                            Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31848][LocalId] of
          GHC.Types.False[3891110078048108556]  ->
            Clash.Sized.Vector.Cons[8214565720323788088] @2
              @(Test.SigType[8214565720323817080]
                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              @1
              _CO_
              <prefixName>"layout_$svoidLayout"
              <prefixName>"layout1"
              <prefixName>"layout2"
              <prefixName>"layout3"
              Clash.Sized.Internal.BitVector.low
              (Clash.Sized.Vector.Cons[8214565720323788088] @1
                 @(Test.SigType[8214565720323817080]
                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                 @0
                 _CO_
                 <prefixName>"layout_$svoidLayout"
                 <prefixName>"layout1"
                 <prefixName>"layout2"
                 <prefixName>"layout3"
                 Clash.Sized.Internal.BitVector.low
                 (Clash.Sized.Vector.Nil[8214565720323788089] @0
                    @(Test.SigType[8214565720323817080]
                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                    _CO_))
          GHC.Types.True[3891110078048108589]  ->
            Clash.Sized.Vector.Cons[8214565720323788088] @2
              @(Test.SigType[8214565720323817080]
                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
              @1
              _CO_
              <prefixName>"layout_$svoidLayout"
              <prefixName>"layout1"
              <prefixName>"layout2"
              <prefixName>"layout3"
              Clash.Sized.Internal.BitVector.low
              (Clash.Sized.Vector.Cons[8214565720323788088] @1
                 @(Test.SigType[8214565720323817080]
                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                 @0
                 _CO_
                 <prefixName>"unitLayout"
                 <prefixName>"headSigFn"
                 (case y[6989586621679044887][LocalId] of
                    Clash.Sized.Vector.Cons[8214565720323788088] m[14304]
                      (_co_[14307] :: GHC.Prim.~#[3674937295934324842]
                                        GHC.Types.Nat[3674937295934325064]
                                        GHC.Types.Nat[3674937295934325064]
                                        1
                                        (GHC.TypeNats.+[3674937295934325068] 0 1))
                        (el[14306] :: Test.SigType[8214565720323817080]
                                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                        (rest[14305] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                          0
                                          (Test.SigType[8214565720323817080]
                                             Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                      el[14306][LocalId])
                 (Clash.Sized.Vector.Nil[8214565720323788089] @0
                    @(Test.SigType[8214565720323817080]
                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                    _CO_))
      c$case_scrut[31848] :: GHC.Types.Bool[3674937295934324744]
      = Clash.Sized.Internal.Index.lt#
          @(GHC.TypeNats.+[3674937295934325068] 2 1)
          <prefixName>"topEntity1_eta"
          (case (case <prefixName>"layout"
                   <prefixName>"layout_$smkPos"
                   result[31733][LocalId] of
                   Clash.Sized.Vector.Cons[8214565720323788088] m[400]
                     (_co_[403] :: GHC.Prim.~#[3674937295934324842]
                                     GHC.Types.Nat[3674937295934325064]
                                     GHC.Types.Nat[3674937295934325064]
                                     2
                                     (GHC.TypeNats.+[3674937295934325068] 1 1))
                       (el[402] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                     (GHC.TypeNats.+[3674937295934325068] 2 1))
                       (rest[401] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                       1
                                       (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                          (GHC.TypeNats.+[3674937295934325068]
                                             2
                                             1))) ->
                     rest[401][LocalId]) of
             Clash.Sized.Vector.Cons[8214565720323788088] m[471]
               (_co_[475] :: GHC.Prim.~#[3674937295934324842]
                               GHC.Types.Nat[3674937295934325064]
                               GHC.Types.Nat[3674937295934325064]
                               1
                               (GHC.TypeNats.+[3674937295934325068] 0 1))
                 (el[530] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                               (GHC.TypeNats.+[3674937295934325068] 2 1))
                 (rest[531] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 0
                                 (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                    (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
               el[530][LocalId])
          (Clash.Sized.Internal.Index.fromInteger# @3 3 0)
      y[6989586621679044938] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31986][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$wild[31990] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                1
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$sel[31992] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 1
                                 (Test.SigType[8214565720323817080]
                                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31992][LocalId]
      y[6989586621679044887] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case Clash.Sized.Vector.splitAt @0 @1
               @(Test.SigType[8214565720323817080]
                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
               (Clash.Promoted.Nat.SNat[8214565720323787967] @0
                  <prefixName>"layout_$svoidLayout"
                  <prefixName>"$s$WBitLayout1"
                  0)
               <prefixName>"unitLayout"
               <prefixName>"singletonSigFn"
               <prefixName>"singletonSigFn1"
               (Clash.Sized.Vector.Cons[8214565720323788088] @1
                  @(Test.SigType[8214565720323817080]
                      Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                  @0
                  _CO_
                  (case y[6989586621679044822][LocalId] of
                     Clash.Sized.Vector.Cons[8214565720323788088] m[4870]
                       (_co_[4873] :: GHC.Prim.~#[3674937295934324842]
                                        GHC.Types.Nat[3674937295934325064]
                                        GHC.Types.Nat[3674937295934325064]
                                        1
                                        (GHC.TypeNats.+[3674937295934325068] 0 1))
                         (el[4872] :: Test.SigType[8214565720323817080]
                                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                         (rest[4871] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                          0
                                          (Test.SigType[8214565720323817080]
                                             Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                       el[4872][LocalId])
                  (Clash.Sized.Vector.Nil[8214565720323788089] @0
                     @(Test.SigType[8214565720323817080]
                         Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                     _CO_)) of
          GHC.Tuple.(,)[3963167672086036486]
            (c$wild[31844] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                0
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$sel[31846] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 1
                                 (Test.SigType[8214565720323817080]
                                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31846][LocalId]
      x[6989586621679044936] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31986][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$sel[31989] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$wild[31988] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31989][LocalId]
      c$case_scrut[31986] :: GHC.Tuple.(,)[3746994889972252676]
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
      = Clash.Sized.Vector.splitAt @1 @1
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          (Clash.Promoted.Nat.SNat[8214565720323787967] @1
             <prefixName>"unitLayout"
             <prefixName>"$s$WBitLayout3"
             1)
          (Clash.Sized.Vector.Cons[8214565720323788088] @2
             @(Test.SigType[8214565720323817080]
                 Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
             @1
             _CO_
             <prefixName>"unitLayout"
             <prefixName>"singletonSigFn"
             <prefixName>"singletonSigFn1"
             (case x[6989586621679044907][LocalId] of
                Clash.Sized.Vector.Cons[8214565720323788088] m[5888]
                  (_co_[5891] :: GHC.Prim.~#[3674937295934324842]
                                   GHC.Types.Nat[3674937295934325064]
                                   GHC.Types.Nat[3674937295934325064]
                                   1
                                   (GHC.TypeNats.+[3674937295934325068] 0 1))
                    (el[5890] :: Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                    (rest[5889] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                     0
                                     (Test.SigType[8214565720323817080]
                                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                  el[5890][LocalId])
             <prefixName>"unitLayout"
             <prefixName>"singletonSigFn"
             <prefixName>"singletonSigFn1"
             (Clash.Sized.Vector.Cons[8214565720323788088] @1
                @(Test.SigType[8214565720323817080]
                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                @0
                _CO_
                (case y[6989586621679044822][LocalId] of
                   Clash.Sized.Vector.Cons[8214565720323788088] m[4870]
                     (_co_[4873] :: GHC.Prim.~#[3674937295934324842]
                                      GHC.Types.Nat[3674937295934325064]
                                      GHC.Types.Nat[3674937295934325064]
                                      1
                                      (GHC.TypeNats.+[3674937295934325068] 0 1))
                       (el[4872] :: Test.SigType[8214565720323817080]
                                      Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                       (rest[4871] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                        0
                                        (Test.SigType[8214565720323817080]
                                           Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                     el[4872][LocalId])
                (Clash.Sized.Vector.Nil[8214565720323788089] @0
                   @(Test.SigType[8214565720323817080]
                       Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                   _CO_)))
      x[6989586621679044914] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case Clash.Sized.Vector.splitAt @1 @0
               @(Test.SigType[8214565720323817080]
                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
               (Clash.Promoted.Nat.SNat[8214565720323787967] @1
                  <prefixName>"unitLayout"
                  <prefixName>"$s$WBitLayout3"
                  1)
               <prefixName>"unitLayout"
               <prefixName>"singletonSigFn"
               <prefixName>"singletonSigFn1"
               (Clash.Sized.Vector.Cons[8214565720323788088] @1
                  @(Test.SigType[8214565720323817080]
                      Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                  @0
                  _CO_
                  (case x[6989586621679044907][LocalId] of
                     Clash.Sized.Vector.Cons[8214565720323788088] m[5888]
                       (_co_[5891] :: GHC.Prim.~#[3674937295934324842]
                                        GHC.Types.Nat[3674937295934325064]
                                        GHC.Types.Nat[3674937295934325064]
                                        1
                                        (GHC.TypeNats.+[3674937295934325068] 0 1))
                         (el[5890] :: Test.SigType[8214565720323817080]
                                        Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                         (rest[5889] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                          0
                                          (Test.SigType[8214565720323817080]
                                             Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
                       el[5890][LocalId])
                  (Clash.Sized.Vector.Nil[8214565720323788089] @0
                     @(Test.SigType[8214565720323817080]
                         Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
                     _CO_)) of
          GHC.Tuple.(,)[3963167672086036486]
            (c$sel[31922] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$wild[31921] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                  0
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31922][LocalId]
      x[6989586621679044907] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     1
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31818][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$sel[31901] :: Clash.Sized.Vector.Vec[8214565720323788085]
                               1
                               (Test.SigType[8214565720323817080]
                                  Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$wild[31900] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                  (GHC.TypeNats.-[3674937295934325076] 2 1)
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31901][LocalId]
      y[6989586621679044822] :: Test.SigType[8214565720323817080]
                                  (Clash.Sized.Vector.Vec[8214565720323788085]
                                     (GHC.TypeNats.-[3674937295934325076] 2 1)
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
      = case c$case_scrut[31818][LocalId] of
          GHC.Tuple.(,)[3963167672086036486]
            (c$wild[31822] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                1
                                (Test.SigType[8214565720323817080]
                                   Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
              (c$sel[31824] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                 (GHC.TypeNats.-[3674937295934325076] 2 1)
                                 (Test.SigType[8214565720323817080]
                                    Clash.Sized.Internal.BitVector.Bit[8214565720323788076])) ->
            c$sel[31824][LocalId]
      c$case_scrut[31818] :: GHC.Tuple.(,)[3746994889972252676]
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  1
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
                               (Clash.Sized.Vector.Vec[8214565720323788085]
                                  (GHC.TypeNats.-[3674937295934325076] 2 1)
                                  (Test.SigType[8214565720323817080]
                                     Clash.Sized.Internal.BitVector.Bit[8214565720323788076]))
      = Clash.Sized.Vector.splitAt @1
          @(GHC.TypeNats.-[3674937295934325076] 2 1)
          @(Test.SigType[8214565720323817080]
              Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
          (Clash.Promoted.Nat.SNat[8214565720323787967] @1
             1)
          c$arg[17344][LocalId]
      result[31733] :: Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         (Clash.Sized.Internal.Index.Index[8214565720323788078]
                            (GHC.TypeNats.+[3674937295934325068] 2 1))
      = Clash.Sized.Vector.Cons[8214565720323788088]
          @2
          @(Clash.Sized.Internal.Index.Index[8214565720323788078]
              (GHC.TypeNats.+[3674937295934325068] 2 1))
          @1
          _CO_
          (Clash.Sized.Internal.Index.fromInteger#
             @(GHC.TypeNats.+[3674937295934325068] 2 1)
             3
             0)
          (Clash.Sized.Vector.Cons[8214565720323788088] @1
             @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                 (GHC.TypeNats.+[3674937295934325068] 2 1))
             @0
             _CO_
             (case (Clash.Sized.Vector.Cons[8214565720323788088]
                      @2
                      @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                          (GHC.TypeNats.+[3674937295934325068] 2 1))
                      @1
                      _CO_
                      (<prefixName>"$s$fEnumIndex_$csucc"
                         <prefixName>"$s$fEnumIndex_$csucc_lvl11"
                         Clash.Sized.Internal.Index.+#
                         @(GHC.TypeNats.+[3674937295934325068] 2 1)
                         (Clash.Transformations.removedArg
                            @GHC.Natural.Natural[3674937295934324786])
                         elH0[279][LocalId]
                         (Clash.Sized.Internal.Index.fromInteger#
                            @(GHC.TypeNats.+[3674937295934325068] 2 1)
                            3
                            1))
                      (Clash.Sized.Vector.Cons[8214565720323788088] @1
                         @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                             (GHC.TypeNats.+[3674937295934325068] 2 1))
                         @0
                         _CO_
                         (<prefixName>"$s$fEnumIndex_$csucc"
                            <prefixName>"$s$fEnumIndex_$csucc_lvl11"
                            Clash.Sized.Internal.Index.+#
                            @(GHC.TypeNats.+[3674937295934325068] 2 1)
                            (Clash.Transformations.removedArg
                               @GHC.Natural.Natural[3674937295934324786])
                            (case (Clash.Sized.Vector.lazyV @1
                                     @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                                         (GHC.TypeNats.+[3674937295934325068] 2 1))
                                     (Clash.Transformations.removedArg
                                        @GHC.Natural.Natural[3674937295934324786])
                                     (case <prefixName>"layout"
                                        <prefixName>"layout_$smkPos"
                                        result[31733][LocalId] of
                                        Clash.Sized.Vector.Cons[8214565720323788088] m[400]
                                          (_co_[403] :: GHC.Prim.~#[3674937295934324842]
                                                          GHC.Types.Nat[3674937295934325064]
                                                          GHC.Types.Nat[3674937295934325064]
                                                          2
                                                          (GHC.TypeNats.+[3674937295934325068]
                                                             1
                                                             1))
                                            (el[402] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                                          (GHC.TypeNats.+[3674937295934325068]
                                                             2
                                                             1))
                                            (rest[401] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                                            1
                                                            (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                                               (GHC.TypeNats.+[3674937295934325068]
                                                                  2
                                                                  1))) ->
                                          rest[401][LocalId])) of
                               Clash.Sized.Vector.Cons[8214565720323788088] m[28]
                                 (_co_[49] :: GHC.Prim.~#[3674937295934324842]
                                                GHC.Types.Nat[3674937295934325064]
                                                GHC.Types.Nat[3674937295934325064]
                                                1
                                                (GHC.TypeNats.+[3674937295934325068]
                                                   0
                                                   1))
                                   (el[30] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                                (GHC.TypeNats.+[3674937295934325068]
                                                   2
                                                   1))
                                   (rest[29] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                                  0
                                                  (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                                     (GHC.TypeNats.+[3674937295934325068]
                                                        2
                                                        1))) ->
                                 el[30][LocalId])
                            (Clash.Sized.Internal.Index.fromInteger#
                               @(GHC.TypeNats.+[3674937295934325068] 2 1)
                               3
                               1))
                         (Clash.Sized.Vector.Nil[8214565720323788089] @0
                            @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                                (GHC.TypeNats.+[3674937295934325068] 2 1))
                            _CO_))) of
                Clash.Sized.Vector.Cons[8214565720323788088] m[10]
                  (_co_[13] :: GHC.Prim.~#[3674937295934324842]
                                 GHC.Types.Nat[3674937295934325064]
                                 GHC.Types.Nat[3674937295934325064]
                                 2
                                 (GHC.TypeNats.+[3674937295934325068] 1 1))
                    (el[12] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                                 (GHC.TypeNats.+[3674937295934325068] 2 1))
                    (rest[11] :: Clash.Sized.Vector.Vec[8214565720323788085]
                                   1
                                   (Clash.Sized.Internal.Index.Index[8214565720323788078]
                                      (GHC.TypeNats.+[3674937295934325068] 2 1))) ->
                  el[12][LocalId])
             (Clash.Sized.Vector.Nil[8214565720323788089] @0
                @(Clash.Sized.Internal.Index.Index[8214565720323788078]
                    (GHC.TypeNats.+[3674937295934325068] 2 1))
                _CO_))
    in result[31996][LocalId]
    It introduces free variables.
    Before: c$arg[17344] :: Test.SigType[8214565720323817080]
                      (Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
    After: elH0[279] :: Clash.Sized.Internal.Index.Index[8214565720323788078]
                   (GHC.TypeNats.+[3674937295934325068] 2 1)
    c$arg[17344] :: Test.SigType[8214565720323817080]
                      (Clash.Sized.Vector.Vec[8214565720323788085]
                         2
                         Clash.Sized.Internal.BitVector.Bit[8214565720323788076])
    CallStack (from HasCallStack):
      error, called at src/Clash/Rewrite/Util.hs:232:13 in clash-lib-1.3.0-inplace:Clash.Rewrite.Util

@martijnbastiaan
Copy link
Member Author

martijnbastiaan commented May 18, 2020

Ah, this only triggers after this patch:

diff --git a/clash-lib/src/Clash/Normalize/Transformations.hs b/clash-lib/src/Clash/Normalize/Transformations.hs
index 8706b3cc..bb2dde34 100644
--- a/clash-lib/src/Clash/Normalize/Transformations.hs
+++ b/clash-lib/src/Clash/Normalize/Transformations.hs
@@ -2148,8 +2148,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
                 | n == 0 -> changed rArg
                 | m == 0 -> changed lArg
                 | otherwise -> do
-                    shouldReduce1 <- List.orM [ shouldReduce ctx
-                                         , isUntranslatableType_not_poly aTy ]
+                    shouldReduce1 <- List.orM [ pure ultra
+                                              , shouldReduce ctx
+                                              , isUntranslatableType_not_poly aTy ]
                     if shouldReduce1
                        then (`mkTicks` ticks) <$> reduceAppend is0 n m aTy lArg rArg
                        else return e
@@ -2159,8 +2160,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
             [vArg]    = Either.lefts args
         case runExcept (tyNatSize tcm nTy) of
           Right n -> do
-            shouldReduce1 <- List.orM [ shouldReduce ctx
-                                 , isUntranslatableType_not_poly aTy ]
+            shouldReduce1 <- List.orM [ pure ultra
+                                      , shouldReduce ctx
+                                      , isUntranslatableType_not_poly aTy ]
             if shouldReduce1
                then (`mkTicks` ticks) <$> reduceHead is0 (n+1) aTy vArg
                else return e
@@ -2170,8 +2172,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
             [vArg]    = Either.lefts args
         case runExcept (tyNatSize tcm nTy) of
           Right n -> do
-            shouldReduce1 <- List.orM [ shouldReduce ctx
-                                 , isUntranslatableType_not_poly aTy ]
+            shouldReduce1 <- List.orM [ pure ultra
+                                      , shouldReduce ctx
+                                      , isUntranslatableType_not_poly aTy ]
             if shouldReduce1
                then (`mkTicks` ticks) <$> reduceTail is0 (n+1) aTy vArg
                else return e
@@ -2181,9 +2184,10 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
             [vArg]    = Either.lefts args
         case runExcept (tyNatSize tcm nTy) of
           Right n -> do
-            shouldReduce1 <- List.orM [ shouldReduce ctx
-                                 , isUntranslatableType_not_poly aTy
-                                 ]
+            shouldReduce1 <- List.orM [ pure ultra
+                                      , shouldReduce ctx
+                                      , isUntranslatableType_not_poly aTy
+                                      ]
             if shouldReduce1
                then (`mkTicks` ticks) <$> reduceLast is0 (n+1) aTy vArg
                else return e
@@ -2193,8 +2197,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
             [vArg]    = Either.lefts args
         case runExcept (tyNatSize tcm nTy) of
           Right n -> do
-            shouldReduce1 <- List.orM [ shouldReduce ctx
-                                 , isUntranslatableType_not_poly aTy ]
+            shouldReduce1 <- List.orM [ pure ultra
+                                      , shouldReduce ctx
+                                      , isUntranslatableType_not_poly aTy ]
             if shouldReduce1
                then (`mkTicks` ticks) <$> reduceInit is0 (n+1) aTy vArg
                else return e
@@ -2213,9 +2218,10 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
         let ([_sArg,vArg],[nTy,aTy]) = Either.partitionEithers args
         case runExcept (tyNatSize tcm nTy) of
           Right n -> do
-            shouldReduce1 <- List.orM [ shouldReduce ctx
-                                 , isUntranslatableType_not_poly aTy
-                                 ]
+            shouldReduce1 <- List.orM [ pure ultra
+                                      , shouldReduce ctx
+                                      , isUntranslatableType_not_poly aTy
+                                      ]
             if shouldReduce1
                then (`mkTicks` ticks) <$> reduceReplicate n aTy eTy vArg
                else return e
@@ -2279,8 +2285,9 @@ reduceNonRepPrim c@(TransformContext is0 ctx) e@(App _ _) | (Prim p, args, ticks
         let ([_sArg,vArg],[nTy,aTy]) = Either.partitionEithers args
         case runExcept (tyNatSize tcm nTy) of
           Right n -> do
-            shouldReduce1 <- List.orM [ shouldReduce ctx
-                                 , isUntranslatableType False aTy ]
+            shouldReduce1 <- List.orM [ pure ultra
+                                      , shouldReduce ctx
+                                      , isUntranslatableType False aTy ]
             if shouldReduce1
                then (`mkTicks` ticks) <$> reduceTReplicate n aTy eTy vArg
                else return e

so it might just be reduceNonRepPrim violating some assumption.

edit: cleaned up patch

@martijnbastiaan
Copy link
Member Author

Actually, I just need to make init, head, or both sensitive to -fclash-compile-ultra and this happens.

@leonschoorl
Copy link
Member

A lot of that patch just seems to be whitespace changes

mergify bot pushed a commit that referenced this issue May 25, 2020
martijnbastiaan added a commit that referenced this issue May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants