Skip to content

Commit ed9b095

Browse files
lmbollenmartijnbastiaan
authored andcommitted
Add PolyKinds as default extension to clash-prelude
`NoPolyKinds` has confused us multiple times because it would needlessly constrain instances to `SomeClass (t :: Type)` instead of the more general `SomeClass (t :: k)`. See the changelog in this commit for more information.
1 parent 37605f1 commit ed9b095

File tree

15 files changed

+56
-23
lines changed

15 files changed

+56
-23
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGED: The `clash-prelude` package now uses `PolyKinds` by default, meaning all its type class instances are now more general than before. As an example, without `PolyKinds`, `BitPack (Proxy a)` would only be defined when `a :: Type`, with the extension it would be defined for any `a :: k`. After this change, some instances in user code might now overlap.

clash-prelude/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Copyright (c) 2013-2016, University of Twente,
22
2016-2019, Myrtle Software Ltd,
3-
2017-2019, QBayLogic B.V., Google Inc.
3+
2017-2025, QBayLogic B.V., Google Inc.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

clash-prelude/clash-prelude.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ common common-options
131131
KindSignatures
132132
MagicHash
133133
NoStarIsType
134+
PolyKinds
134135
PostfixOperators
135136
ScopedTypeVariables
136137
StandaloneDeriving

clash-prelude/src/Clash/Annotations/SynthesisAttributes.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-|
22
Copyright : (C) 2018, Google Inc.,
3-
2021-2023, QBayLogic B.V.
3+
2021-2025, QBayLogic B.V.
44
License : BSD2 (see the file LICENSE)
55
Maintainer : QBayLogic B.V. <[email protected]>
66
@@ -13,7 +13,6 @@
1313
{-# LANGUAGE DeriveAnyClass #-}
1414
{-# LANGUAGE CPP #-}
1515
{-# LANGUAGE NoGeneralizedNewtypeDeriving #-}
16-
{-# LANGUAGE PolyKinds #-}
1716
{-# LANGUAGE QuasiQuotes #-}
1817
{-# LANGUAGE TemplateHaskellQuotes #-}
1918

clash-prelude/src/Clash/Annotations/TH.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ makeTopEntity 'topEntity
5151
{-# LANGUAGE GADTs #-}
5252
{-# LANGUAGE LambdaCase #-}
5353
{-# LANGUAGE PatternSynonyms #-}
54-
{-# LANGUAGE PolyKinds #-}
5554
{-# LANGUAGE StandaloneDeriving #-}
5655
{-# LANGUAGE TemplateHaskell #-}
5756
{-# LANGUAGE TypeFamilies #-}

clash-prelude/src/Clash/Class/BitPack/Internal.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import Clash.Sized.Internal.BitVector
5858
>>> :m -Prelude
5959
>>> :set -XDataKinds
6060
>>> import Clash.Prelude
61+
>>> import Data.Proxy
6162
-}
6263

6364
-- | Convert data to/from a 'BitVector'. This allows functions to be defined
@@ -92,7 +93,7 @@ import Clash.Sized.Internal.BitVector
9293
-- places.
9394
--
9495
-- Clash provides some generic functions on packable types in the prelude, such
95-
-- as indexing into packable stuctures (see "Clash.Class.BitPack.BitIndex") and
96+
-- as indexing into packable structures (see "Clash.Class.BitPack.BitIndex") and
9697
-- bitwise reduction of packable data (see "Clash.Class.BitPack.BitReduction").
9798
--
9899
class KnownNat (BitSize a) => BitPack a where
@@ -478,7 +479,16 @@ instance ( BitPack a
478479
) => BitPack (Either a b)
479480

480481
instance BitPack a => BitPack (Maybe a)
481-
instance BitPack (Proxy a) => BitPack (Proxy a)
482+
483+
-- | Any 'Proxy' has a bit size of 0 and hence packs to @0 :: BitVector 0@.
484+
--
485+
-- >>> pack (Proxy @())
486+
-- 0
487+
-- >>> pack (Proxy @5)
488+
-- 0
489+
-- >>> pack (Proxy @Bool)
490+
-- 0
491+
instance BitPack (Proxy a)
482492

483493
instance BitPack a => BitPack (Complex a)
484494
instance BitPack a => BitPack (Down a)

clash-prelude/src/Clash/Class/HasDomain/Common.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ License : BSD2 (see the file LICENSE)
44
Maintainer : Christiaan Baaij <[email protected]>
55
-}
66

7-
{-# LANGUAGE PolyKinds #-}
87
{-# LANGUAGE TypeFamilies #-}
98

109
module Clash.Class.HasDomain.Common {-# DEPRECATED "Experimental feature multiple hidden has been removed. This module will therefore be removed in Clash 1.12." #-}

clash-prelude/src/Clash/Class/HasDomain/HasSingleDomain.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-|
22
Copyright : (C) 2019, Myrtle Software Ltd
3-
2022, QBayLogic B.V.
3+
2022-2025, QBayLogic B.V.
44
License : BSD2 (see the file LICENSE)
55
Maintainer : QBayLogic B.V. <[email protected]>
66
@@ -10,7 +10,6 @@ Internals for "Clash.Class.HasDomain"
1010
{-# LANGUAGE ConstraintKinds #-}
1111
{-# LANGUAGE CPP #-}
1212
{-# LANGUAGE FlexibleInstances #-}
13-
{-# LANGUAGE PolyKinds #-}
1413
{-# LANGUAGE TemplateHaskell #-}
1514
{-# LANGUAGE TypeFamilies #-}
1615
{-# LANGUAGE UndecidableInstances #-}

clash-prelude/src/Clash/Class/HasDomain/HasSpecificDomain.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-|
22
Copyright : (C) 2019, Myrtle Software Ltd
3+
2022-2025, QBayLogic B.V.
34
License : BSD2 (see the file LICENSE)
45
Maintainer : Christiaan Baaij <[email protected]>
56
@@ -10,7 +11,6 @@ Internals for "Clash.Class.HasDomain"
1011
{-# LANGUAGE CPP #-}
1112
{-# LANGUAGE FlexibleInstances #-}
1213
{-# LANGUAGE MultiParamTypeClasses #-}
13-
{-# LANGUAGE PolyKinds #-}
1414
{-# LANGUAGE TemplateHaskell #-}
1515
{-# LANGUAGE TypeFamilies #-}
1616
{-# LANGUAGE UndecidableInstances #-}

clash-prelude/src/Clash/NamedTypes.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ fifo @System
3434
-}
3535

3636
{-# LANGUAGE NoGeneralizedNewtypeDeriving #-}
37-
{-# LANGUAGE PolyKinds #-}
3837

3938
{-# LANGUAGE Safe #-}
4039

0 commit comments

Comments
 (0)