packages feed

unbound-kind-generics 0.2.0.0 → 0.2.1.0

raw patch · 3 files changed

+32/−7 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Unbound.Generics.LocallyNameless.Kind.Derive: AutoAlpha :: a -> AutoAlpha a
+ Unbound.Generics.LocallyNameless.Kind.Derive: [unAutoAlpha] :: AutoAlpha a -> a
+ Unbound.Generics.LocallyNameless.Kind.Derive: instance (Data.Typeable.Internal.Typeable a, Unbound.Generics.LocallyNameless.Kind.Derive.GenericAlpha a, GHC.Show.Show a) => Unbound.Generics.LocallyNameless.Alpha.Alpha (Unbound.Generics.LocallyNameless.Kind.Derive.AutoAlpha a)
+ Unbound.Generics.LocallyNameless.Kind.Derive: instance GHC.Classes.Eq a => GHC.Classes.Eq (Unbound.Generics.LocallyNameless.Kind.Derive.AutoAlpha a)
+ Unbound.Generics.LocallyNameless.Kind.Derive: instance GHC.Show.Show a => GHC.Show.Show (Unbound.Generics.LocallyNameless.Kind.Derive.AutoAlpha a)
+ Unbound.Generics.LocallyNameless.Kind.Derive: newtype AutoAlpha a

Files

src/Unbound/Generics/LocallyNameless/Kind/Derive.hs view
@@ -11,8 +11,10 @@ {-# language TypeApplications #-} {-# language ConstraintKinds #-} module Unbound.Generics.LocallyNameless.Kind.Derive (+  -- For use with DerivingVia+  AutoAlpha(..)   -- Default definitions for 'Alpha'-  aeqDefK+, aeqDefK , fvAnyDefK , closeDefK , openDefK@@ -49,6 +51,29 @@ import Generics.Kind  type GenericAlpha a = (GenericK a, GAlphaK (RepK a) LoT0 LoT0)++newtype AutoAlpha a = AutoAlpha { unAutoAlpha :: a }+                    deriving (Eq, Show)++instance (Typeable a, GenericAlpha a, Show a) => Alpha (AutoAlpha a) where+  aeq' ctx (AutoAlpha x) (AutoAlpha y)+    = aeqDefK ctx x y+  fvAny' ctx nfn (AutoAlpha x) +    = AutoAlpha <$> fvAnyDefK ctx nfn x+  close ctx npf = AutoAlpha . closeDefK ctx npf . unAutoAlpha+  open  ctx npf = AutoAlpha . openDefK  ctx npf . unAutoAlpha+  isPat       = isPatDefK   . unAutoAlpha+  isTerm      = isTermDefK  . unAutoAlpha+  isEmbed     = isEmbedDefK . unAutoAlpha+  nthPatFind  = nthPatFindDefK  . unAutoAlpha+  namePatFind = namePatFindDefK . unAutoAlpha+  swaps' ctx perm = AutoAlpha . swapsDefK ctx perm . unAutoAlpha+  lfreshen' ctx (AutoAlpha x) cont +    = lfreshenDefK ctx x (\y p -> cont (AutoAlpha y) p)+  freshen' ctx (AutoAlpha x)+    = (\(y, p) -> (AutoAlpha y, p)) <$> freshenDefK ctx x+  acompare' ctx (AutoAlpha x) (AutoAlpha y)+    = acompareDefK ctx x y  aeqDefK :: forall a. (GenericAlpha a)         => AlphaCtx -> a -> a -> Bool
src/Unbound/Generics/LocallyNameless/Kind/Example.hs view
@@ -9,6 +9,7 @@ {-# language TypeApplications #-} {-# language ScopedTypeVariables #-} {-# language TemplateHaskell #-}+{-# language DerivingVia #-} -- | Example of how to use `unbound-kind-generics` module Unbound.Generics.LocallyNameless.Kind.Example where @@ -31,7 +32,7 @@ $(deriveGenericK ''Expr)  eval :: Typeable t => Expr t -> FreshM (Expr t)-eval (V x) = fail $ "unbound variable " ++ show x+eval (V x) = error $ "unbound variable " ++ show x eval e@(Lam {}) = return e eval (App e1 e2) = do   v1 <- eval e1@@ -42,7 +43,7 @@      (x, body) <- unbind bnd      let body' = subst x v2 body      eval body'-   _ -> fail "application of non-lambda"+   _ -> error "application of non-lambda"  example :: forall a. Typeable a => Expr (a -> a) example =@@ -55,8 +56,6 @@  deriving instance Show (Expr t) -- {- instance GenericK (Expr t) LoT0 where   type RepK (Expr t) =@@ -96,6 +95,7 @@   lfreshen'   = lfreshenDefK   freshen'    = freshenDefK   acompare'   = acompareDefK+-- deriving via (AutoAlpha (Expr t)) instance Typeable t => Alpha (Expr t)  instance (Typeable small, Typeable big)          => Subst (Expr small) (Expr big) where
unbound-kind-generics.cabal view
@@ -4,14 +4,14 @@ -- http://haskell.org/cabal/users-guide/  name:                unbound-kind-generics-version:             0.2.0.0+version:             0.2.1.0 synopsis:            Support for programming with names and binders using kind-generics description:         Specify the binding structure of your data type with an                      expressive set of type combinators, and unbound-generics                      handles the rest!  Automatically derives                      alpha-equivalence, free variable calculation,                      capture-avoiding substitution, and more. See-                     @Unbound.Generics.LocallyNameless.Kind@ to get started.+                     @Unbound.Generics.LocallyNameless.Kind.Derive@ to get started.                      .                      This is an independent re-implementation of <http://hackage.haskell.org/package/unbound-generics unbound-generics>                      but using <https://hackage.haskell.org/package/kind-generics kind-generics>