Skip to content

Commit

Permalink
Update singletons to version 3.0, which is compatible with GHC 9.0
Browse files Browse the repository at this point in the history
(cherry picked from commit 1770abf)
  • Loading branch information
gergoerdi authored and mergify-bot committed Mar 18, 2021
1 parent a5f5194 commit 22cf355
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 37 deletions.
25 changes: 23 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ packages:
./benchmark/profiling/run
./clash-term

write-ghc-environment-files: always

-- index state, to go along with the cabal.project.freeze file. update the index
-- state by running `cabal update` twice and looking at the index state it
-- displays to you (as the second update will be a no-op)
index-state: 2021-02-25T05:27:39Z
index-state: 2021-03-18T06:58:19Z

-- For some reason the `clash-testsuite` executable fails to run without
-- this, as it cannot find the related library...
Expand Down Expand Up @@ -43,4 +45,23 @@ optional-packages:
./clash-cores

allow-newer:
brick:base
brick:base,
vector-binary-instances:base,
cryptohash-sha256:base

source-repository-package
type: git
location: https://github.com/kcsongor/generic-lens.git
tag: 8e1fc7dcf444332c474fca17110d4bc554db08c8
subdir: generic-lens-core

source-repository-package
type: git
location: https://github.com/kcsongor/generic-lens.git
tag: 8e1fc7dcf444332c474fca17110d4bc554db08c8
subdir: generic-lens

source-repository-package
type: git
location: https://github.com/haskell-hint/hint.git
tag: abdb192eace46ef71b7b4a2d4a67654248f8dbdb
2 changes: 1 addition & 1 deletion clash-prelude/clash-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Library
recursion-schemes >= 5.1 && < 5.3,
QuickCheck >= 2.7 && < 2.15,
reflection >= 2 && < 2.2,
singletons >= 1.0 && < 3.0,
singletons >= 2.0 && < 3.1,
template-haskell >= 2.12.0.0 && < 2.18,
th-abstraction >= 0.2.10 && < 0.5.0,
th-lift >= 0.7.0 && < 0.9,
Expand Down
2 changes: 1 addition & 1 deletion clash-prelude/src/Clash/Explicit/Signal/Delayed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import Prelude ((.), (<$>), (<*>), id, Num(..))
import Data.Coerce (coerce)
import Data.Kind (Type)
import Data.Proxy (Proxy (..))
import Data.Singletons.Prelude (Apply, TyFun, type (@@))
import Data.Singletons (Apply, TyFun, type (@@))
import GHC.TypeLits (KnownNat, Nat, type (+), type (^), type (*))

import Clash.Sized.Vector
Expand Down
6 changes: 3 additions & 3 deletions clash-prelude/src/Clash/Sized/RTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import Data.Default.Class (Default (..))
import Data.Either (isLeft)
import Data.Foldable (toList)
import Data.Kind (Type)
import Data.Singletons.Prelude (Apply, TyFun, type (@@))
import Data.Singletons (Apply, TyFun, type (@@))
import Data.Proxy (Proxy (..))
import GHC.TypeLits (KnownNat, Nat, type (+), type (^), type (*))
import Language.Haskell.TH.Syntax (Lift(..))
Expand Down Expand Up @@ -85,7 +85,7 @@ import Clash.XException
>>> :set -XUndecidableInstances
>>> import Clash.Prelude
>>> import Data.Kind
>>> import Data.Singletons.Prelude (Apply, TyFun)
>>> import Data.Singletons (Apply, TyFun)
>>> import Data.Proxy
>>> data IIndex (f :: TyFun Nat Type) :: Type
>>> type instance Apply IIndex l = Index ((2^l)+1)
Expand Down Expand Up @@ -333,7 +333,7 @@ the form of 'dtfold':
@
{\-\# LANGUAGE UndecidableInstances \#-\}
import Data.Singletons.Prelude
import Data.Singletons
import Data.Proxy
data IIndex (f :: 'TyFun' Nat *) :: *
Expand Down
6 changes: 3 additions & 3 deletions clash-prelude/src/Clash/Sized/Vector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import Data.Default.Class (Default (..))
import qualified Data.Foldable as F
import Data.Kind (Type)
import Data.Proxy (Proxy (..))
import Data.Singletons.Prelude (TyFun,Apply,type (@@))
import Data.Singletons (TyFun,Apply,type (@@))
import GHC.TypeLits (CmpNat, KnownNat, Nat, type (+), type (-), type (*),
type (^), type (<=), natVal)
import GHC.Base (Int(I#),Int#,isTrue#)
Expand Down Expand Up @@ -2128,7 +2128,7 @@ lazyV = lazyV' (repeat ())
-- now correctly define /append'/:
--
-- @
-- import Data.Singletons.Prelude
-- import Data.Singletons
-- import Data.Proxy
--
-- data Append (m :: Nat) (a :: *) (f :: 'TyFun' Nat *) :: *
Expand Down Expand Up @@ -2258,7 +2258,7 @@ the form of 'dtfold':
@
{\-\# LANGUAGE UndecidableInstances \#-\}
import Data.Singletons.Prelude
import Data.Singletons
import Data.Proxy
data IIndex (f :: 'TyFun' Nat *) :: *
Expand Down
8 changes: 7 additions & 1 deletion tests/shouldwork/Basic/T1591.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
module T1591 where

import Clash.Prelude
import Data.Singletons.Prelude

import Data.Singletons
import Data.Singletons.TH

#if MIN_VERSION_singletons(3,0,0)
import Prelude.Singletons
#else
import Data.Singletons.Prelude
#endif

$(singletons [d|
countStates :: Nat -> Nat -> Nat
Expand Down
4 changes: 2 additions & 2 deletions tests/shouldwork/RTree/TFold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Data.Kind (Type)

import Data.Proxy
#if MIN_VERSION_singletons(2,4,0)
import Data.Singletons.Prelude hiding (type (+))
import Data.Singletons hiding (type (+))
#else
import Data.Singletons.Prelude
import Data.Singletons
#endif

data IIndex (f :: TyFun Nat Type) :: Type
Expand Down
4 changes: 2 additions & 2 deletions tests/shouldwork/Vector/DFold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module DFold where
import Clash.Prelude
import Clash.Explicit.Testbench
#if MIN_VERSION_singletons(2,4,0)
import Data.Singletons.Prelude hiding (type (+))
import Data.Singletons hiding (type (+))
#else
import Data.Singletons.Prelude
import Data.Singletons
#endif
import Data.Proxy
import Data.Kind (Type)
Expand Down
4 changes: 2 additions & 2 deletions tests/shouldwork/Vector/DTFold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module DTFold where
import Clash.Prelude
import Clash.Explicit.Testbench
#if MIN_VERSION_singletons(2,4,0)
import Data.Singletons.Prelude hiding (type (+))
import Data.Singletons hiding (type (+))
#else
import Data.Singletons.Prelude
import Data.Singletons
#endif
import Data.Proxy
import Data.Kind (Type)
Expand Down
23 changes: 4 additions & 19 deletions testsuite/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import System.Directory
(createDirectoryIfMissing, removeDirectoryRecursive, getCurrentDirectory,
doesDirectoryExist, makeAbsolute)
import System.Environment
import System.Exit
(exitWith, ExitCode(ExitSuccess, ExitFailure))
import System.FilePath ((</>))
import System.Info
import System.Process (readCreateProcessWithExitCode, proc)
import GHC.Conc (numCapabilities)
import GHC.Stack
import GHC.IO.Unsafe (unsafePerformIO)
Expand Down Expand Up @@ -112,22 +109,10 @@ setClashEnvs :: HasCallStack => RunWith -> IO ()
setClashEnvs Global = setEnv "GHC_ENVIRONMENT" "-"
setClashEnvs Stack = pure ()
setClashEnvs Cabal = do
-- Make sure environment variable exists
let cp = proc "cabal" ["--write-ghc-environment-files=always", "v2-run", "--", "clash", "--help"]
(exitCode, stdout, stderr) <- readCreateProcessWithExitCode cp ""
case exitCode of
ExitSuccess -> do
binDir <- cabalClashBinDir
path <- getEnv "PATH"
setEnv "PATH" (binDir <> ":" <> path)
setCabalPackagePaths
ExitFailure _ -> do
putStrLn "'cabal run clash' failed"
putStrLn ">>> stdout:"
putStrLn stdout
putStrLn ">>> stderr:"
putStrLn stderr
exitWith exitCode
binDir <- cabalClashBinDir
path <- getEnv "PATH"
setEnv "PATH" (binDir <> ":" <> path)
setCabalPackagePaths

clashTestRoot
:: [[TestName] -> TestTree]
Expand Down
13 changes: 13 additions & 0 deletions testsuite/clash-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ library
build-depends:
deepseq >=1.4 && <1.5,
concurrent-extra >=0.7 && <0.8,
singletons,
generic-lens,
interpolate,
mtl,
Expand All @@ -94,6 +95,18 @@ executable clash-testsuite
main-is: Main.hs
ghc-options: -threaded -with-rtsopts=-N

build-tool-depends:
clash-ghc:clash

build-depends:
containers,
clash-testsuite

if impl(ghc >= 9.0.0)
build-depends:
singletons,
singletons-base,
singletons-th
else
build-depends:
singletons < 3.0
3 changes: 2 additions & 1 deletion testsuite/src/Test/Tasty/Clash.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}

module Test.Tasty.Clash where

Expand Down

0 comments on commit 22cf355

Please sign in to comment.