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

Updated flake #5

Draft
wants to merge 28 commits into
base: wavewave-flake
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c74f4cb
Add CI via Github Actions.
sellout Mar 14, 2022
fe43fa4
Make `traverseC` category-polymorphic.
sellout Jan 5, 2022
aed4963
Add some missing Additive instances.
sellout Feb 11, 2022
48453ec
Add missing imports for Additive instances
mikesperber Aug 11, 2022
60489f4
Reverse examples/plugin dependency relationship.
sellout Jan 11, 2022
06ca984
checkpoint coercion analysis
nomeata Apr 6, 2022
73aa321
Less warnings
nomeata Apr 7, 2022
eff8a10
If no FuncorCat instance is found, use coerce
nomeata Apr 7, 2022
8210dc3
Unbreak gold tests.
mikesperber Sep 18, 2022
4184beb
Add support for ghc 9.0.2, 9.2.4.
mikesperber Feb 13, 2023
2f3817f
Add HLS config file.
mikesperber Feb 13, 2023
4bc2491
Fix comment about the command to update the Nix pin.
mikesperber Feb 13, 2023
c498072
INLINE crossF
mikesperber Feb 13, 2023
adaa333
Add tanh to FloatingCat.
mikesperber Feb 13, 2023
38b15a8
Optimize sqrtC derivative.
rschlotterbeck Jan 24, 2023
84900a2
Unbreak compile of concat-graphics on ghc 9.
mikesperber Feb 13, 2023
39c3a05
Catify min, max.
rschlotterbeck Jun 17, 2021
999d8a7
Add ghc rule.
rschlotterbeck Oct 10, 2022
04d367c
Call optimizeCoercion before checking for FunCo.
mikesperber Jun 9, 2022
f0013c4
Make TypeRep bindings let-float.
mikesperber Sep 7, 2022
c191ded
Try lam Let compose later.
mikesperber Apr 5, 2022
aaca2f9
Unbreak plugin build on ghc 9.0.2
mikesperber Feb 13, 2023
00ae6bc
Unbreak gold test.
mikesperber Feb 13, 2023
a0f2aff
Turn misc-examples and misc-trace into executables
mikesperber Mar 1, 2023
c920a3e
use nix flakes providing overlay
wavewave May 5, 2022
dfa8372
Convert some `test-suite`s to `executable`s
sellout Mar 1, 2023
6bbea8f
Fix Haddock
sellout Mar 2, 2023
a8f27cf
Refactor Nix flake
sellout Dec 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: concat
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
ghc:
- "8.10.7"
- "9.0.2"
- "9.2.4"
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: "3.6.0.0"
- run: cabal v2-update
- run: cabal v2-freeze $CONFIG
- uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal new-build all
- run: cabal new-test gold-tests
5 changes: 0 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ source-repository-package
tag: master
subdir: verilog

source-repository-package
type: git
location: https://github.com/expipiplus1/vector-sized.git
tag: master

packages:
./inline/concat-inline.cabal
./plugin/concat-plugin.cabal
Expand Down
1 change: 1 addition & 0 deletions classes/concat-classes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ library
ConCat.MinMax
ConCat.Category
ConCat.AltCat
ConCat.Oops
ghc-options: -O2
-- -fobject-code here avoids error "mkPluginUsage: file not found"
-- with GHCi. See https://gitlab.haskell.org/ghc/ghc/issues/16093.
Expand Down
11 changes: 11 additions & 0 deletions classes/src/ConCat/Additive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import Data.Monoid (Monoid(..), Sum(..), Product(..))
import Data.Semigroup (Semigroup(..))
import Data.Complex hiding (magnitude)
import Data.Ratio
import Data.Int
import Data.Word
import Foreign.C.Types (CSChar, CInt, CShort, CLong, CLLong, CIntMax, CFloat, CDouble)
import GHC.Generics (U1(..),Par1(..),(:*:)(..),(:.:)(..))
import GHC.TypeLits (KnownNat)
Expand Down Expand Up @@ -73,6 +75,10 @@ instance Additive () where
{-# INLINE (^+^) #-} }

ScalarType(Int)
ScalarType(Int16)
ScalarType(Int32)
ScalarType(Int64)
ScalarType(Int8)
ScalarType(Integer)
ScalarType(Float)
ScalarType(Double)
Expand All @@ -84,6 +90,11 @@ ScalarType(CLLong)
ScalarType(CIntMax)
ScalarType(CDouble)
ScalarType(CFloat)
ScalarType(Word)
ScalarType(Word16)
ScalarType(Word32)
ScalarType(Word64)
ScalarType(Word8)

instance Integral a => Additive (Ratio a) where
zero = 0
Expand Down
30 changes: 25 additions & 5 deletions classes/src/ConCat/AltCat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE UndecidableInstances #-}

#if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)
{-# LANGUAGE NoStarIsType #-}
#endif

{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_GHC -Wno-inline-rule-shadowing #-}
Expand Down Expand Up @@ -381,6 +379,7 @@ Op0(logC,FloatingCat k a => a `k` a)
Op0(cosC,FloatingCat k a => a `k` a)
Op0(sinC,FloatingCat k a => a `k` a)
Op0(sqrtC,FloatingCat k a => a `k` a)
Op0(tanhC,FloatingCat k a => a `k` a)
-- Op0(powC,FloatingCat k a => a `k` a)

Op0(fromIntegralC,FromIntegralCat k a b => a `k` b)
Expand Down Expand Up @@ -1064,9 +1063,24 @@ Catify(distribute, distributeC)
Catify(tabulate , tabulateC)
Catify(index , indexC)

traverseC :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
traverseC f = sequenceA . fmap f
-- traverseC f = sequenceAC . fmapC f
traverseC ::
forall k t f a b.
( Category k,
FunctorCat k t,
OkFunctor k f,
TraversableCat k t f,
Ok k a,
Ok k b
) =>
a `k` f b ->
t a `k` f (t b)
traverseC f =
sequenceAC . fmapC f
<+ okFunctor @k @t @(f b)
<+ okFunctor @k @f @(t b)
<+ okFunctor @k @t @a
<+ okFunctor @k @t @b
<+ okFunctor @k @f @b
{-# INLINE traverseC #-}

Catify(traverse, traverseC)
Expand Down Expand Up @@ -1141,6 +1155,12 @@ separateProd (unFinite \\ knownMul @m @n -> x) =

#-}

{-# RULES

"uncurry (,)" uncurry (,) = id

#-}

-- type Strong k h a = (ProductCat k, ZipCat k h, PointedCat k h a)

-- -- Functorial strength
Expand Down
18 changes: 11 additions & 7 deletions classes/src/ConCat/Category.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE RecursiveDo #-}

#if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)
{-# LANGUAGE NoStarIsType #-}
#endif

{-# OPTIONS_GHC -Wall #-}

Expand Down Expand Up @@ -1368,6 +1365,7 @@ instance (FloatingCat k a, con a) => FloatingCat (Constrained con k) a where
cosC = Constrained cosC
sinC = Constrained sinC
sqrtC = Constrained sqrtC
tanhC = Constrained tanhC

instance (RealFracCat k a b, con a, con b) => RealFracCat (Constrained con k) a b where
floorC = Constrained floorC
Expand Down Expand Up @@ -1698,7 +1696,7 @@ instance (FractionalCat k a, FractionalCat k' a) => FractionalCat (k :**: k') a
PINLINER(divideC)

class Ok k a => FloatingCat k a where
expC, logC, cosC, sinC, sqrtC :: a `k` a
expC, logC, cosC, sinC, sqrtC, tanhC :: a `k` a
-- powC :: (a :* a) `k` a

-- ln :: Floating a => a -> a
Expand All @@ -1710,12 +1708,14 @@ instance Floating a => FloatingCat (->) a where
cosC = IC.inline cos
sinC = IC.inline sin
sqrtC = IC.inline sqrt
tanhC = IC.inline tanh
-- powC = IC.inline (**)
{-# OPINLINE expC #-}
{-# OPINLINE logC #-}
{-# OPINLINE cosC #-}
{-# OPINLINE sinC #-}
{-# OPINLINE sqrtC #-}
{-# OPINLINE tanhC #-}

#ifdef KleisliInstances
instance (Monad m, Floating a) => FloatingCat (Kleisli m) a where
Expand All @@ -1724,6 +1724,7 @@ instance (Monad m, Floating a) => FloatingCat (Kleisli m) a where
cosC = arr cosC
sinC = arr sinC
sqrtC = arr sqrtC
tanhC = arr tanh
-- powC = arr powC
#endif

Expand All @@ -1733,6 +1734,7 @@ instance FloatingCat U2 a where
cosC = U2
sinC = U2
sqrtC = U2
tanhC = U2
-- powC = U2

instance (FloatingCat k a, FloatingCat k' a) => FloatingCat (k :**: k') a where
Expand All @@ -1741,11 +1743,13 @@ instance (FloatingCat k a, FloatingCat k' a) => FloatingCat (k :**: k') a where
cosC = cosC :**: cosC
sinC = sinC :**: sinC
sqrtC = sqrtC :**: sqrtC
tanhC = tanhC :**: tanhC
PINLINER(expC)
PINLINER(logC)
PINLINER(cosC)
PINLINER(sinC)
PINLINER(sqrtC)
PINLINER(tanhC)
-- powC = powC :**: powC
-- PINLINER(powC)

Expand Down Expand Up @@ -1815,7 +1819,7 @@ class BottomCat k a b where
-- bottomC = bottomC &&& bottomC

instance (BottomCat k a b, ClosedCat k, Ok4 k z b a (z -> b)) => BottomCat k a (z -> b) where
bottomC = curry (bottomC . exl) <+ okProd @k @a @ z
bottomC = curry (bottomC . exl) <+ okProd @k @a @z

instance BottomCat (->) a b where bottomC = error "bottomC for (->) evaluated"

Expand Down Expand Up @@ -2075,7 +2079,7 @@ class ({- Pointed h, -} OkFunctor k h, Ok k a) => PointedCat k h a where
-- class (Ok k a, Num a) => SumCat k h a where
-- sumC :: h a `k` a

class (Ok k a, Additive a) => AddCat k h a where
class Ok k a => AddCat k h a where
sumAC :: h a `k` a

-- class IxSummable n => IxSummableCat k n where
Expand Down Expand Up @@ -2330,7 +2334,7 @@ instance OkIxProd (->) h where okIxProd = Entail (Sub Dict)

instance Zip h => IxMonoidalPCat (->) h where
crossF = zipWith id -- 2018-02-07 notes
{-# OPINLINE crossF #-}
{-# INLINE crossF #-}

instance (Representable h, Zip h, Pointed h) => IxProductCat (->) h where
exF = tabulate (flip index)
Expand Down
2 changes: 1 addition & 1 deletion classes/src/ConCat/Experimental/A.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import Data.Constraint (Dict(..),(:-)(..),refl,trans,(\\))
-- import Data.Key
-- import Data.IntMap ()

import ConCat.Misc (Yes1,type (&+&),inNew,inNew2,oops,type (+->)(..))
import ConCat.Misc (Yes1,type (&+&),inNew,inNew2,type (+->)(..))
-- import ConCat.Free.VectorSpace
-- import ConCat.Free.LinearRow (lapplyL,OkLF,idL,compL,exlL,exrL,forkL,inlL,inrL,joinL,HasL(..))
-- import ConCat.Rep
Expand Down
11 changes: 3 additions & 8 deletions classes/src/ConCat/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

-- | Miscellany

module ConCat.Misc where
module ConCat.Misc(module ConCat.Misc, oops) where

import GHC.Types (Constraint)

Expand All @@ -34,12 +34,12 @@ import Data.Monoid (Endo(..))
import Data.Semigroup (Semigroup(..))
import Data.Complex (Complex)
import GHC.Generics hiding (R)
-- import Unsafe.Coerce (unsafeCoerce) -- for oops
import GHC.Stack (errorWithStackTrace) -- for oops
import GHC.TypeLits

import Control.Newtype.Generics

import ConCat.Oops

{--------------------------------------------------------------------
Type abbreviations
-------------------------------------------------------------------
Expand Down Expand Up @@ -257,11 +257,6 @@ data PseudoFun = PseudoFun { pseudoArgs :: Int } deriving (Typeable,Data)
-- pseudoFun :: Int -> PseudoFun
-- pseudoFun = PseudoFun

-- | Pseudo function to fool GHC's divergence checker.
oops :: String -> b
oops str = errorWithStackTrace ("Oops: "++str)
{-# NOINLINE oops #-}

-- In the use of ‘errorWithStackTrace’ (imported from GHC.Stack):
-- Deprecated: "'error' appends the call stack now"

Expand Down
11 changes: 11 additions & 0 deletions classes/src/ConCat/Oops.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# OPTIONS_GHC -O0 -fno-strictness #-}
module ConCat.Oops(oops) where

-- Both -O0 -fno-strictness are necessary to keep ghc 9 from
-- discovering that this bombs.

-- | Pseudo function to fool GHC's divergence checker.
oops :: String -> b
oops str = error ("Oops: "++str)
{-# NOINLINE oops #-}

Loading