Making sure that it builds is annoying

This commit is contained in:
Pingu 2023-05-20 17:22:43 +02:00
parent 7ac02ccb3c
commit 40ea83e76d
14 changed files with 250 additions and 136 deletions

View File

@ -1,5 +0,0 @@
# Revision history for PPU
## 0.1.0.0 -- YYYY-mm-dd
* First version. Released on an unsuspecting world.

230
PPU.cabal
View File

@ -1,130 +1,130 @@
cabal-version: 3.4 cabal-version: 3.4
-- The cabal-version field refers to the version of the .cabal specification, name: PPU
-- and can be different from the cabal-install (the tool) version and the version: 1.0
-- Cabal (the library) version you are using. As such, the Cabal (the library) license: MIT
-- version used must be equal or greater than the version stated in this field. author: Nor Führ <nor@acorneroftheweb.com>
-- Starting from the specification version 2.2, the cabal-version field must be maintainer: Nor Führ <nor@acorneroftheweb.com>
-- the first thing in the cabal file.
-- Initial package description 'PPU' generated by common common-options
-- 'cabal init'. For further documentation, see: default-extensions:
-- http://haskell.org/cabal/users-guide/ BangPatterns
-- BinaryLiterals
-- The name of the package. ConstraintKinds
name: PPU DataKinds
DefaultSignatures
DeriveAnyClass
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
DerivingStrategies
InstanceSigs
KindSignatures
LambdaCase
NoStarIsType
PolyKinds
RankNTypes
ScopedTypeVariables
StandaloneDeriving
TupleSections
TypeApplications
TypeFamilies
TypeOperators
ViewPatterns
-- The package version. -- TemplateHaskell is used to support convenience functions such as
-- See the Haskell package versioning policy (PVP) for standards -- 'listToVecTH' and 'bLit'.
-- guiding when and how versions should be incremented. TemplateHaskell
-- https://pvp.haskell.org QuasiQuotes
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.0
-- A short (one-line) description of the package. -- Prelude isn't imported by default as Clash offers Clash.Prelude
synopsis: Pingu Processing Unit NoImplicitPrelude
ghc-options:
-Wall -Wcompat
-haddock
-- A longer description of the package. -- Plugins to support type-level constraint solving on naturals
-- description: -fplugin GHC.TypeLits.Extra.Solver
-fplugin GHC.TypeLits.Normalise
-fplugin GHC.TypeLits.KnownNat.Solver
-- URL for the project homepage or repository. -- Clash needs access to the source code in compiled modules
homepage: https://git.acorneroftheweb.com/pingu/ppu -fexpose-all-unfoldings
-- The license under which the package is released. -- Worker wrappers introduce unstable names for functions that might have
license: MIT -- blackboxes attached for them. You can disable this, but be sure to add
-- a no-specialize pragma to every function with a blackbox.
-fno-worker-wrapper
-- The file containing the license text. -- Strict annotations - while sometimes preventing space leaks - trigger
license-file: LICENSE -- optimizations Clash can't deal with. See:
--
-- https://github.com/clash-lang/clash-compiler/issues/2361
--
-- These flags disables these optimizations. Note that the fields will
-- remain strict.
-fno-unbox-small-strict-fields
-fno-unbox-strict-fields
build-depends:
base,
Cabal,
-- The package author(s). -- clash-prelude will set suitable version bounds for the plugins
author: Nor Führ clash-prelude >= 1.6.4 && < 1.8,
ghc-typelits-natnormalise,
ghc-typelits-extra,
ghc-typelits-knownnat,
-- An email address to which users can send suggestions, bug reports, and patches.
maintainer: nor@acorneroftheweb.com
-- A copyright notice.
-- copyright:
build-type: Simple
-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README.
extra-doc-files: CHANGELOG.md
-- Extra source files to be distributed with the package, such as examples, or a tutorial module.
-- extra-source-files:
common warnings
ghc-options: -Wall
library library
-- Import common warning flags. import: common-options
import: warnings hs-source-dirs: src
exposed-modules:
Example.Project
default-language: Haskell2010
-- Modules exported by the library. -- Builds the executable 'clash', with PPU project in scope
exposed-modules: MyLib executable clash
main-is: app/Clash.hs
default-language: Haskell2010
Build-Depends: base, clash-ghc, PPU
if !os(Windows)
ghc-options: -dynamic
-- Modules included in this library but not exported. -- Builds the executable 'clashi', with PPU project in scope
-- other-modules: executable clashi
main-is: app/Clashi.hs
default-language: Haskell2010
if !os(Windows)
ghc-options: -dynamic
build-depends: base, clash-ghc, PPU
-- LANGUAGE extensions used by modules in this package. test-suite doctests
-- other-extensions: type: exitcode-stdio-1.0
default-language: Haskell2010
main-is: doctests.hs
ghc-options: -Wall -Wcompat -threaded
hs-source-dirs: tests
build-depends:
base,
PPU,
doctest-parallel >= 0.2 && < 0.4,
-- Other library packages from which modules are imported. test-suite test-library
build-depends: base ^>=4.17.0.0 import: common-options
default-language: Haskell2010
-- Directories containing source files. hs-source-dirs: tests
hs-source-dirs: src type: exitcode-stdio-1.0
ghc-options: -threaded
-- Base language which the package is written in. main-is: unittests.hs
default-language: GHC2021 other-modules:
Tests.Example.Project
executable PPU build-depends:
-- Import common warning flags. PPU,
import: warnings QuickCheck,
hedgehog,
-- .hs or .lhs file containing the Main module. tasty >= 1.2 && < 1.5,
main-is: Main.hs tasty-hedgehog,
tasty-th
-- Modules included in this executable, other than Main.
-- other-modules:
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
-- Other library packages from which modules are imported.
build-depends:
base ^>=4.17.0.0,
PPU
-- Directories containing source files.
hs-source-dirs: app
-- Base language which the package is written in.
default-language: GHC2021
test-suite PPU-test
-- Import common warning flags.
import: warnings
-- Base language which the package is written in.
default-language: GHC2021
-- Modules included in this executable, other than Main.
-- other-modules:
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
-- The interface type and version of the test suite.
type: exitcode-stdio-1.0
-- Directories containing source files.
hs-source-dirs: test
-- The entrypoint to the test suite.
main-is: Main.hs
-- Test dependencies.
build-depends:
base ^>=4.17.0.0,
PPU

6
app/Clash.hs Normal file
View File

@ -0,0 +1,6 @@
import Clash.Main (defaultMain)
import Prelude
import System.Environment (getArgs)
main :: IO ()
main = getArgs >>= defaultMain

6
app/Clashi.hs Normal file
View File

@ -0,0 +1,6 @@
import Clash.Main (defaultMain)
import Prelude
import System.Environment (getArgs)
main :: IO ()
main = getArgs >>= defaultMain . ("--interactive":)

View File

@ -1,8 +0,0 @@
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc

13
cabal.project Normal file
View File

@ -0,0 +1,13 @@
packages:
PPU.cabal
write-ghc-environment-files: always
-- Eliminates the need for `--enable-tests`, which is needed for HLS.
tests: true
-- Works around: https://github.com/recursion-schemes/recursion-schemes/issues/128. This
-- shouldn't harm (runtime) performance of Clash, as we only use recursion-schemes with
-- TemplateHaskell.
package recursion-schemes
optimization: 0

19
src/Example/Project.hs Normal file
View File

@ -0,0 +1,19 @@
module Example.Project (topEntity, plus) where
import Clash.Prelude
-- | Add two numbers. Example:
--
-- >>> plus 3 5
-- 8
plus :: Signed 8 -> Signed 8 -> Signed 8
plus a b = a + b
-- | 'topEntity' is Clash's equivalent of 'main' in other programming
-- languages. Clash will look for it when compiling 'Example.Project'
-- and translate it to HDL. While polymorphism can be used freely in
-- Clash projects, a 'topEntity' must be monomorphic and must use non-
-- recursive types. Or, to put it hand-wavily, a 'topEntity' must be
-- translatable to a static number of wires.
topEntity :: Signed 8 -> Signed 8 -> Signed 8
topEntity = plus

View File

@ -1,4 +0,0 @@
module MyLib (someFunc) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"

7
stack.yaml Normal file
View File

@ -0,0 +1,7 @@
resolver: lts-19.33
extra-deps:
- clash-ghc-1.6.4
- clash-prelude-1.6.4
- clash-lib-1.6.4
- concurrent-supply-0.1.8

40
stack.yaml.lock Normal file
View File

@ -0,0 +1,40 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages:
- completed:
hackage: clash-ghc-1.6.4@sha256:43e4c9c949bf9623633f08bb09bb4495578b517be4e99140d9ea22dd2a9cd13b,9042
pantry-tree:
sha256: 9484d37cd6c8cb0217a02cf020b6398dbe1a68fa332472b40cfb511ce54a743a
size: 3634
original:
hackage: clash-ghc-1.6.4
- completed:
hackage: clash-prelude-1.6.4@sha256:67b5c26ad7c712e23f5d54187d691cbb007931a89b4aabd4a738c307d71b2a27,17249
pantry-tree:
sha256: b12774016a4f9bd456ecdf7bc1e5182d33ef4ac9e16db0f344d27189a26bfe2d
size: 13292
original:
hackage: clash-prelude-1.6.4
- completed:
hackage: clash-lib-1.6.4@sha256:336e57d424852f2ad9285b6fa820e634f32d39d52755d3245d5f4ac04ea37f85,13688
pantry-tree:
sha256: 750ffc9d2f5ed3690f6a2a7da46090970594dbbcf8a6b55d785e8f809b4dfbf1
size: 22460
original:
hackage: clash-lib-1.6.4
- completed:
hackage: concurrent-supply-0.1.8@sha256:9373f4868ad28936a7b93781b214ef4afdeacf377ef4ac729583073491c9f9fb,1627
pantry-tree:
sha256: bdfaa167ae3249f858ba248aea2e9b97ab9b13af6e68c73b7c3192e717e11b83
size: 400
original:
hackage: concurrent-supply-0.1.8
snapshots:
- completed:
sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4
size: 619204
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml
original: lts-19.33

View File

@ -1,4 +0,0 @@
module Main (main) where
main :: IO ()
main = putStrLn "Test suite not yet implemented."

View File

@ -0,0 +1,26 @@
module Tests.Example.Project where
import Prelude
import Test.Tasty
import Test.Tasty.TH
import Test.Tasty.Hedgehog
import Hedgehog ((===))
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Example.Project (plus)
prop_plusIsCommutative :: H.Property
prop_plusIsCommutative = H.property $ do
a <- H.forAll (Gen.integral (Range.linear minBound maxBound))
b <- H.forAll (Gen.integral (Range.linear minBound maxBound))
plus a b === plus b a
tests :: TestTree
tests = $(testGroupGenerator)
main :: IO ()
main = defaultMain tests

8
tests/doctests.hs Normal file
View File

@ -0,0 +1,8 @@
module Main where
import System.Environment (getArgs)
import Test.DocTest (mainFromCabal)
main :: IO ()
main = mainFromCabal "simple" =<< getArgs

10
tests/unittests.hs Normal file
View File

@ -0,0 +1,10 @@
import Prelude
import Test.Tasty
import qualified Tests.Example.Project
main :: IO ()
main = defaultMain $ testGroup "."
[ Tests.Example.Project.tests
]