diff --git a/.gitignore b/.gitignore index 6106a19..ade40e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.stack-work +/dist-newstyle *.graphula test.db diff --git a/flake.lock b/flake.lock index 32861e7..287a2f6 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -39,21 +39,24 @@ "freckle": { "inputs": { "flake-utils": "flake-utils_2", + "nixpkgs-22-11": "nixpkgs-22-11", "nixpkgs-23-05": "nixpkgs-23-05", "nixpkgs-master-2023-05-06": "nixpkgs-master-2023-05-06", "nixpkgs-master-2023-07-18": "nixpkgs-master-2023-07-18", "nixpkgs-master-2023-09-15": "nixpkgs-master-2023-09-15", + "nixpkgs-master-2024-01-27": "nixpkgs-master-2024-01-27", "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-stable-2023-07-25": "nixpkgs-stable-2023-07-25", - "nixpkgs-unstable-2023-10-21": "nixpkgs-unstable-2023-10-21" + "nixpkgs-unstable-2023-10-21": "nixpkgs-unstable-2023-10-21", + "nixpkgs-unstable-2024-02-20": "nixpkgs-unstable-2024-02-20" }, "locked": { "dir": "main", - "lastModified": 1701736713, - "narHash": "sha256-LdXNxnzhvAXxX52d79DSTzbKUpnMB5dlZaxXa0KhYEM=", + "lastModified": 1708474311, + "narHash": "sha256-nO5JLvAshKODkumut9gnMrb9Uqh9PPNnWfXPM3P/kRw=", "owner": "freckle", "repo": "flakes", - "rev": "89b21c33e0705ecc2280625e25c7d94654fd43bb", + "rev": "ace145f01993ddc109d86a4c47e37ffe06481df3", "type": "github" }, "original": { @@ -63,13 +66,29 @@ "type": "github" } }, + "nixpkgs-22-11": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-23-05": { "locked": { - "lastModified": 1701362232, - "narHash": "sha256-GVdzxL0lhEadqs3hfRLuj+L1OJFGiL/L7gCcelgBlsw=", + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d2332963662edffacfddfad59ff4f709dde80ffe", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", "type": "github" }, "original": { @@ -127,13 +146,29 @@ "type": "github" } }, + "nixpkgs-master-2024-01-27": { + "locked": { + "lastModified": 1706367331, + "narHash": "sha256-AqgkGHRrI6h/8FWuVbnkfFmXr4Bqsr4fV23aISqj/xg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "160b762eda6d139ac10ae081f8f78d640dd523eb", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "160b762eda6d139ac10ae081f8f78d640dd523eb", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { - "lastModified": 1701263465, - "narHash": "sha256-lNXUIlkfyDyp9Ox21hr+wsEf/IBklLvb6bYcyeXbdRc=", + "lastModified": 1708294118, + "narHash": "sha256-evZzmLW7qoHXf76VCepvun1esZDxHfVRFUJtumD7L2M=", "owner": "nixos", "repo": "nixpkgs", - "rev": "50aa30a13c4ab5e7ba282da460a3e3d44e9d0eb3", + "rev": "e0da498ad77ac8909a980f07eff060862417ccf7", "type": "github" }, "original": { @@ -175,6 +210,22 @@ "type": "github" } }, + "nixpkgs-unstable-2024-02-20": { + "locked": { + "lastModified": 1708296515, + "narHash": "sha256-FyF489fYNAUy7b6dkYV6rGPyzp+4tThhr80KNAaF/yY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", @@ -185,11 +236,11 @@ }, "stable": { "locked": { - "lastModified": 1701802827, - "narHash": "sha256-wTn0lpV75Uv6tU6haEypNsmnJJPb0hpaMIy/4uf5AiQ=", + "lastModified": 1709218635, + "narHash": "sha256-nytX/MkfqeTD4z7bMq4QRXcHxO9B3vRo9tM6fMtPFA8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a804fc878d7ba1558b960b4c64b0903da426ac41", + "rev": "068d4db604958d05d0b46c47f79b507d84dbc069", "type": "github" }, "original": { @@ -231,11 +282,11 @@ }, "unstable": { "locked": { - "lastModified": 1701718080, - "narHash": "sha256-6ovz0pG76dE0P170pmmZex1wWcQoeiomUZGggfH9XPs=", + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2c7f3c0fb7c08a0814627611d9d7d45ab6d75335", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", "type": "github" }, "original": { diff --git a/graphula.cabal b/graphula.cabal index a80cf85..fcf982b 100644 --- a/graphula.cabal +++ b/graphula.cabal @@ -3,8 +3,6 @@ cabal-version: 1.12 -- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack --- --- hash: 77f36204ab2afc392bf0f4eb7413aaf8ff36c25b86f28dde5747f3ed9121f0d4 name: graphula version: 2.1.0.0 @@ -46,6 +44,8 @@ library Paths_graphula hs-source-dirs: src + default-extensions: + RoleAnnotations ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missing-import-lists -Wno-safe -Wno-unsafe build-depends: HUnit @@ -77,6 +77,8 @@ test-suite readme Paths_graphula hs-source-dirs: test + default-extensions: + RoleAnnotations ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude -Wno-missing-import-lists -Wno-safe -Wno-unsafe -pgmL markdown-unlit build-depends: QuickCheck diff --git a/package.yaml b/package.yaml index 1d49f8e..c6083fc 100644 --- a/package.yaml +++ b/package.yaml @@ -34,6 +34,9 @@ when: dependencies: - base < 5 +default-extensions: + - RoleAnnotations + library: source-dirs: - src diff --git a/src/Graphula.hs b/src/Graphula.hs index 09532dc..c5caf97 100755 --- a/src/Graphula.hs +++ b/src/Graphula.hs @@ -191,12 +191,18 @@ data Args backend n m = Args , gen :: IORef QCGen } +type role Args representational representational representational + newtype RunDB backend n m = RunDB (forall b. ReaderT backend n b -> m b) +type role RunDB representational representational representational + newtype GraphulaT n m a = GraphulaT {runGraphulaT' :: ReaderT (Args SqlBackend n m) m a} deriving newtype (Functor, Applicative, Monad, MonadIO, MonadReader (Args SqlBackend n m)) +type role GraphulaT representational representational nominal + instance MonadTrans (GraphulaT n) where lift = GraphulaT . lift diff --git a/src/Graphula/Dependencies.hs b/src/Graphula/Dependencies.hs index d7e3193..13e12fa 100644 --- a/src/Graphula/Dependencies.hs +++ b/src/Graphula/Dependencies.hs @@ -127,6 +127,8 @@ class HasDependencies a where newtype Only a = Only {fromOnly :: a} deriving stock (Eq, Show, Ord, Generic, Functor, Foldable, Traversable) +type role Only representational + only :: a -> Only a only = Only @@ -142,8 +144,12 @@ data KeySourceType newtype Required a = Required a +type role Required representational + newtype Optional a = Optional (Maybe a) +type role Optional representational + -- | When a user of Graphula inserts, this wraps the key they provide. -- For 'SourceExternal' a key is required; for others it's optional. type family KeySourceTypeM (t :: KeySourceType) :: Type -> Type where diff --git a/src/Graphula/Dependencies/Generic.hs b/src/Graphula/Dependencies/Generic.hs index ec0c509..13fed35 100644 --- a/src/Graphula/Dependencies/Generic.hs +++ b/src/Graphula/Dependencies/Generic.hs @@ -22,6 +22,8 @@ data Match t = NoMatch t | Match t +type role Match representational + type family DependenciesTypeInstance nodeTy depsTy where DependenciesTypeInstance nodeTy depsTy = 'Text "‘type Dependencies " diff --git a/src/Graphula/Idempotent.hs b/src/Graphula/Idempotent.hs index d7a7fa6..104d0ff 100644 --- a/src/Graphula/Idempotent.hs +++ b/src/Graphula/Idempotent.hs @@ -43,6 +43,8 @@ newtype GraphulaIdempotentT m a = GraphulaIdempotentT , MonadReader (IORef (m ())) ) +type role GraphulaIdempotentT representational nominal + instance MonadUnliftIO m => MonadUnliftIO (GraphulaIdempotentT m) where {-# INLINE withRunInIO #-} withRunInIO inner = GraphulaIdempotentT $ withRunInIO $ \run -> diff --git a/src/Graphula/Logged.hs b/src/Graphula/Logged.hs index e47a9a3..016d3cf 100644 --- a/src/Graphula/Logged.hs +++ b/src/Graphula/Logged.hs @@ -56,6 +56,8 @@ newtype GraphulaLoggedT m a = GraphulaLoggedT , MonadReader (IORef (Seq Text)) ) +type role GraphulaLoggedT representational nominal + instance MonadUnliftIO m => MonadUnliftIO (GraphulaLoggedT m) where {-# INLINE withRunInIO #-} withRunInIO inner = diff --git a/src/Graphula/Node.hs b/src/Graphula/Node.hs index a2d54eb..c850627 100644 --- a/src/Graphula/Node.hs +++ b/src/Graphula/Node.hs @@ -68,6 +68,8 @@ newtype NodeOptions a = NodeOptions } deriving stock (Generic) +type role NodeOptions nominal + instance Semigroup (NodeOptions a) where (<>) = gmappend {-# INLINE (<>) #-} @@ -80,6 +82,8 @@ instance Monoid (NodeOptions a) where newtype Kendo m a = Kendo {appKendo :: a -> m a} deriving stock (Generic) +type role Kendo representational nominal + instance Monad m => Semigroup (Kendo m a) where Kendo f <> Kendo g = Kendo $ f <=< g {-# INLINE (<>) #-}