Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions clash-prelude/src/Clash/Class/BitPack/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Maintainer : QBayLogic B.V. <[email protected]>
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# LANGUAGE PolyKinds #-} -- Required for BitPack (KnownNat n) => BitPack (Proxy n) instances
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this on initial review, but what does BitPack (KnownNat n) mean? I initially mentally autocorrected this to KnownNat n => BitPack (Proxy n) which makes sense although it is overly specific: it forces n to be a Nat which needs PolyKinds. How about:

Suggested change
{-# LANGUAGE PolyKinds #-} -- Required for BitPack (KnownNat n) => BitPack (Proxy n) instances
{-# LANGUAGE PolyKinds #-} -- Required for BitPack (Proxy (n :: Nat)) instances

It's still overly specific, but at least it makes sense. I don't think a BitPack (KnownNat n) constraint means anything?

{-# LANGUAGE Trustworthy #-}

{-# OPTIONS_GHC -fplugin=GHC.TypeLits.Extra.Solver #-}
Expand Down Expand Up @@ -58,6 +58,7 @@ import Clash.Sized.Internal.BitVector
>>> :m -Prelude
>>> :set -XDataKinds
>>> import Clash.Prelude
>>> import Data.Proxy
-}

-- | Convert data to/from a 'BitVector'. This allows functions to be defined
Expand Down Expand Up @@ -478,7 +479,15 @@ instance ( BitPack a
) => BitPack (Either a b)

instance BitPack a => BitPack (Maybe a)
instance BitPack (Proxy a) => BitPack (Proxy a)

-- |
-- >>> pack (Proxy @())
-- 0
-- >>> pack (Proxy @5)
-- 0
-- >>> pack (Proxy @Bool)
-- 0
instance BitPack (Proxy a)

instance BitPack a => BitPack (Complex a)
instance BitPack a => BitPack (Down a)
Expand Down
Loading