fcf-family 0.2.0.1 → 0.2.0.2
raw patch · 4 files changed
+35/−9 lines, 4 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- fcf-family.cabal +2/−2
- src/Fcf/Family/Meta.hs +1/−0
- test/Main.hs +28/−7
CHANGELOG.md view
@@ -2,6 +2,10 @@ [Current version](https://gitlab.com/lysxia/fcf-family/-/blob/main/fcf-family/CHANGELOG.md) +## 0.2.0.2 - 2024-01-24++- Compatibility up to GHC 9.12.1+ ## 0.2.0.1 - Compatibility with GHC 9.8.1
fcf-family.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: fcf-family-version: 0.2.0.1+version: 0.2.0.2 synopsis: Family of families: featherweight defunctionalization description: Promote regular type families to first-class,@@ -30,7 +30,7 @@ first-class-families, containers, template-haskell,- base >=4.15 && < 4.20+ base >=4.15 && < 4.22 hs-source-dirs: src default-language: Haskell2010
src/Fcf/Family/Meta.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE DataKinds, PolyKinds, TemplateHaskell, TypeFamilies #-}+{-# OPTIONS_GHC -Wno-orphans #-} -- | 'Eval' and friends as part of the family of families. module Fcf.Family.Meta () where
test/Main.hs view
@@ -1,9 +1,21 @@-{-# LANGUAGE AllowAmbiguousTypes, DataKinds, PolyKinds, ScopedTypeVariables, TemplateHaskell, TypeApplications, TypeFamilies, TypeOperators #-}+{-# LANGUAGE+ AllowAmbiguousTypes,+ CPP,+ DataKinds,+ PolyKinds,+ ScopedTypeVariables,+ TemplateHaskell,+ TypeApplications,+ TypeFamilies,+ TypeOperators #-}+{-# OPTIONS_GHC -Wno-orphans -fdefer-type-errors #-} -- {-# OPTIONS_GHC -ddump-splices #-} module Main where +import Control.Exception (TypeError(..), try) import Data.Type.Bool+import GHC.Stack (HasCallStack) import GHC.TypeNats import Fcf.Core@@ -20,11 +32,13 @@ fcfify ''Fst fcfify ''Snd +#if __GLASGOW_HASKELL__ >= 910+type (:+:) = MkName "ghc-internal" "GHC.Internal.TypeNats" "+"+type If_ = MkName "ghc-internal" "GHC.Internal.Data.Type.Bool" "If"+#else type (:+:) = MkName "base" "GHC.TypeNats" "+" type If_ = MkName "base" "Data.Type.Bool" "If"--equals :: forall a b. (a ~ b) => IO ()-equals = pure ()+#endif main :: IO () main = do@@ -33,14 +47,15 @@ equate @(Eval (Family If_ P1 '( 'False, '(1, '(2, '()))))) @2 -- Test applyFamily- equals @(Eval $(applyFamily ''(+) [ [t|3|] , [t|4|] ])) @7- equals @(Eval $(applyFamily ''If [ [t|'True|] , [t|Int|] , [t|()|] ])) @Int+ equate @(Eval $(applyFamily ''(+) [ [t|3|] , [t|4|] ])) @7+ equate @(Eval $(applyFamily ''If [ [t|'True|] , [t|Int|] , [t|()|] ])) @Int -- Test kind inference: the two Any under If should have the same type. equate @(Eval (Family If_ P1 '( 'True, '(Any, '(Any, '()))))) @Any -- The following should fail because Family_ is untyped (unlike Family)- -- equate @(Eval (Family_ If_ P1 '( 'True, '(Any, '(Any, '()))))) @Any+ -- -fdefer-type-errors only stops at lets.+ shouldFail $ let err = equate @(Eval (Family_ If_ P1 '( 'True, '(Any, '(Any, '()))))) @Any in err -- Utils @@ -48,3 +63,9 @@ equate :: forall a b. (a ~ b) => IO () equate = pure ()++shouldFail :: HasCallStack => IO () -> IO ()+shouldFail run = try run >>= \r ->+ case r of+ Left (TypeError _) -> pure ()+ Right () -> error "This test should have failed, but didn't"