Skip to content

Commit

Permalink
Merge branch 'release/0.3.0.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abrar committed Dec 10, 2022
2 parents d3ce121 + c290833 commit 3c48555
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 102 deletions.
1 change: 0 additions & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
matrix:
ghc: ['8.6.5', '8.8.4', '8.10.2']
os: ['ubuntu-latest', 'macos-latest']
exclude:
runs-on: ${{ matrix.os }}

name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 0.3.0.0

* Fix singleV: absent query /= present query for deleted item
* Use Commutative instead of the deprecated Additive
* Update for constraints-extras 0.4

## 0.2.1.0

Expand Down
6 changes: 3 additions & 3 deletions reflex-platform/github.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"owner": "reflex-frp",
"repo": "reflex-platform",
"branch": "release/0.9.2.0",
"branch": "develop",
"private": false,
"rev": "123a6f487ca954fd983f6d4cd6b2a69d4c463d10",
"sha256": "16q1rq0rwi6l28fv46q8m0hvb9rxrzf574j865vaz04xy8d5p1ya"
"rev": "6c8830e059a6d2859cb1b65acefed3c2f1d216d3",
"sha256": "06kv45yq8qan0p22wzj5c9mx11ns1wddyqjr1xasjjkf6gaf0080"
}
5 changes: 4 additions & 1 deletion reflex-platform/thunk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
} else (import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
}) {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
Expand Down
2 changes: 1 addition & 1 deletion release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let
} {};
})
];
rp = import ./reflex-platform { inherit haskellOverlaysPost; };
rp = import ./reflex-platform { inherit haskellOverlaysPost; __useNewerCompiler = true; };
in
{ ghc = rp.ghc.callCabal2nix "vessel" ./. {};
ghcjs = rp.ghcjs.callCabal2nix "vessel" ./. {};
Expand Down
21 changes: 10 additions & 11 deletions src/Data/Vessel/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ module Data.Vessel.Class where
import Control.Arrow ((***))
import Control.Monad.Writer.Strict (Writer, execWriter, tell)
import Data.Align
import qualified Data.Dependent.Map as DMap'
import Data.Dependent.Map.Monoidal (MonoidalDMap(..))
import qualified Data.Dependent.Map.Monoidal as DMap
import Data.Foldable
import Data.Functor.Compose
import Data.Witherable
import GHC.Generics
import Data.Functor.Identity
import Data.GADT.Compare
import Data.Map.Monoidal (MonoidalMap(..))
import Data.Maybe (fromMaybe)
import Data.Proxy
import Data.Semigroup
import Data.These
import Data.Maybe (fromMaybe)
import Data.Functor.Identity
import GHC.Generics
import Reflex.Query.Class
import Data.Proxy
import Data.Map.Monoidal (MonoidalMap (..))
import Data.Dependent.Map.Monoidal (MonoidalDMap (..))
import Data.GADT.Compare
import qualified Data.Dependent.Map.Monoidal as DMap
import qualified Data.Dependent.Map as DMap'
import Witherable

import Data.Vessel.Internal

Expand Down Expand Up @@ -370,4 +370,3 @@ filterV f = mapMaybeV (\x -> if f x then Just x else Nothing)

-- | a completely empty view.
instance View Proxy

21 changes: 11 additions & 10 deletions src/Data/Vessel/DependentMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@ import Data.Aeson
import Data.Bifunctor
import Data.Constraint.Extras
import Data.Constraint.Forall
import qualified Data.Dependent.Map as DMap'
import Data.Dependent.Map.Monoidal (MonoidalDMap(..))
import qualified Data.Dependent.Map.Monoidal as MonoidalDMap
import Data.Functor.Compose
import Data.GADT.Compare
import Data.Some (Some(Some))
import GHC.Generics
import Data.Functor.Identity
import qualified Data.Dependent.Map.Monoidal as DMap
import Data.Dependent.Sum
import Data.Dependent.Sum.Orphans ()
import Data.Functor.Compose
import Data.Functor.Identity
import Data.GADT.Compare
import Data.Patch (Group(..))
import Data.Semigroup.Commutative
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Patch (Group(..), Additive)
import qualified Data.Dependent.Map as DMap'
import qualified Data.Dependent.Map.Monoidal as DMap
import Data.Some (Some(Some))
import GHC.Generics

import Data.Vessel.Class
import Data.Vessel.Selectable
import Data.Vessel.Internal
import Data.Vessel.Selectable

-- | A functor-indexed container corrresponding to DMap k v.
newtype DMapV (k :: x -> *) (v :: x -> *) g = DMapV { unDMapV :: MonoidalDMap k (g :.: v) }
Expand All @@ -53,7 +54,7 @@ deriving instance (GCompare k, Has' Eq k (g :.: v), Has' Ord k (g :.: v)) => Ord
deriving instance (GCompare k, Has' Semigroup k (g :.: v)) => Semigroup (DMapV k v g)
deriving instance (GCompare k, Has' Semigroup k (g :.: v), Has' Monoid k (g :.: v)) => Monoid (DMapV k v g)
deriving instance (GCompare k, Has' Semigroup k (g :.: v), Has' Monoid k (g :.: v), Has' Group k (g :.: v)) => Group (DMapV k v g)
deriving instance (GCompare k, Has' Semigroup k (g :.: v), Has' Monoid k (g :.: v), Has' Group k (g :.: v), Has' Additive k (g :.: v)) => Additive (DMapV k v g)
deriving instance (GCompare k, Has' Semigroup k (g :.: v), Has' Monoid k (g :.: v), Has' Group k (g :.: v), Has' Commutative k (g :.: v)) => Commutative (DMapV k v g)

instance (Has' ToJSON k (g :.: v), ForallF ToJSON k) => ToJSON (DMapV k v g)

Expand Down
7 changes: 3 additions & 4 deletions src/Data/Vessel/Disperse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
module Data.Vessel.Disperse where

import Control.Arrow ((***))
import Data.Witherable
import Data.Align
import Data.Map.Monoidal (MonoidalMap (..))
import Data.Foldable hiding (null)
import Data.Map.Monoidal (MonoidalMap(..))
import qualified Data.Map.Monoidal as Map
import Data.These
import Data.Foldable hiding (null)
import Witherable

import Data.Vessel.Internal

Expand Down Expand Up @@ -73,4 +73,3 @@ instance Ord k => Disperse (MonoidalMap k) where
None -> nil
One k v -> fmap (Map.singleton k) v
Split pivot _l _r -> uncurry (alignWith (mergeThese unionDistinctAsc)) $ condense *** condense $ splitLT pivot row

9 changes: 4 additions & 5 deletions src/Data/Vessel/Identity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
module Data.Vessel.Identity where

import Data.Aeson
import Data.Patch (Group(..), Additive)
import GHC.Generics
import Data.Functor.Compose
import Data.Functor.Const
import Data.Functor.Identity
import Data.Patch (Group(..))
import Data.Semigroup.Commutative
import Data.These
import GHC.Generics

import Data.Vessel.Class
import Data.Vessel.Selectable
import Data.Vessel.ViewMorphism

-- | A functor-indexed container corresponding to Identity. (i.e. a single non-deletable item)
newtype IdentityV (a :: *) (g :: * -> *) = IdentityV { unIdentityV :: g a }
deriving (Eq, Ord, Show, Read, Semigroup, Monoid, Group, Additive, Generic, ToJSON, FromJSON)
deriving (Eq, Ord, Show, Read, Semigroup, Monoid, Group, Commutative, Generic, ToJSON, FromJSON)

instance View (IdentityV a) where
cropV f (IdentityV s) (IdentityV x) = Just $ IdentityV $ f s x
Expand Down Expand Up @@ -82,5 +83,3 @@ handleIdentityVSelector k f (IdentityV xs) = (\y -> IdentityV $ k y xs) <$> f
-- | Non-existentialized map; since the contained value is known
mapIdentityV :: (f a -> g a) -> IdentityV a f -> IdentityV a g
mapIdentityV f (IdentityV xs) = IdentityV (f xs)


25 changes: 13 additions & 12 deletions src/Data/Vessel/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,26 @@ module Data.Vessel.Internal where

import Control.Arrow ((***))
import Data.Aeson
import Data.Coerce
import Data.Constraint.Extras
import Data.Constraint.Forall
import Data.Dependent.Map.Internal (DMap (..))
import qualified Data.Dependent.Map as DMap'
import Data.Dependent.Map.Internal (DMap(..))
import Data.Dependent.Map.Monoidal (MonoidalDMap(..))
import Data.Functor.Compose
import Data.Functor.Const
import Data.GADT.Compare
import Data.Some (Some(Some))
import Data.Map.Monoidal (MonoidalMap (..))
import qualified Data.Map.Monoidal as Map
import Data.These
import Data.Patch (Group(..), Additive)
import Data.Coerce
import Data.Set (Set)
import Data.Witherable
import qualified Data.Map as Map'
import qualified Data.Map.Merge.Strict as Map'
import Data.Map.Monoidal (MonoidalMap(..))
import qualified Data.Map.Monoidal as Map
import Data.Patch (Group(..))
import Data.Semigroup.Commutative
import Data.Set (Set)
import Data.Some (Some(Some))
import Data.These
import GHC.Generics
import Witherable

import qualified Data.Dependent.Map.Monoidal as DMap
-- import qualified Data.Dependent.Map as DMap'
Expand All @@ -63,7 +64,7 @@ instance Monoid (v g) => Monoid (FlipAp g v) where
instance Group (v g) => Group (FlipAp g v) where
negateG (FlipAp x) = FlipAp (negateG x)

instance Additive (v g) => Additive (FlipAp g v)
instance Commutative (v g) => Commutative (FlipAp g v)


-- A single Vessel key/value pair, essentially a choice of container type, together with a corresponding container.
Expand All @@ -88,9 +89,9 @@ instance forall k g. (FromJSON (Some k), HasV FromJSON k g) => FromJSON (VSum k
instance (Has' Group f g, Has' Semigroup f g, GCompare f) => Group (MonoidalDMap f g) where
negateG (MonoidalDMap m) = MonoidalDMap (DMap'.mapWithKey (\k v -> has' @Group @g k (negateG v)) m)

instance (Has' Group f g, Has' Semigroup f g, GCompare f) => Additive (MonoidalDMap f g)
instance (Has' Group f g, Has' Semigroup f g, GCompare f) => Commutative (MonoidalDMap f g)

instance (Additive (f (g a))) => Additive (Compose f g a)
instance (Commutative (f (g a))) => Commutative (Compose f g a)

------- Miscellaneous stuff to be moved elsewhere -------

Expand Down
17 changes: 9 additions & 8 deletions src/Data/Vessel/Map.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ import Control.Applicative
import Data.Aeson
import Data.Align
import Data.Foldable
import Data.Functor.Identity
import Data.Functor.Compose
import Data.Map.Monoidal (MonoidalMap (..))
import Data.Patch (Group(..), Additive)
import GHC.Generics
import qualified Data.Map.Monoidal as Map
import Data.Functor.Identity
import qualified Data.Map as Map'
import qualified Data.Map.Merge.Strict as Map'
import Data.Map.Monoidal (MonoidalMap(..))
import qualified Data.Map.Monoidal as Map
import Data.Patch (Group(..))
import Data.Semigroup.Commutative
import Data.Set (Set)
import GHC.Generics

import Data.Vessel.Class hiding (empty)
import Data.Vessel.Selectable
import Data.Vessel.Disperse
import Data.Vessel.Selectable
import Data.Vessel.ViewMorphism

-- | A functor-indexed container corresponding to Map k v.
Expand All @@ -60,7 +61,7 @@ instance (Ord k, Eq g, Monoid g) => Monoid (MapV k v (Const g)) where

instance (Ord k, Eq g, Group g) => Group (MapV k v (Const g)) where
negateG (MapV (MonoidalMap xs)) = MapV $ MonoidalMap $ fmap negateG xs
instance (Ord k, Eq g, Group g, Additive g) => Additive (MapV k v (Const g))
instance (Ord k, Eq g, Group g, Commutative g) => Commutative (MapV k v (Const g))

instance (Ord k1, Ord k2, Monoid g, Eq g) => Semigroup (MapV k1 v (Compose (MonoidalMap k2) (Const g))) where
MapV (MonoidalMap xs) <> MapV (MonoidalMap ys) = MapV $ MonoidalMap $ Map'.merge Map'.preserveMissing Map'.preserveMissing (Map'.zipWithMaybeMatched $ \_ (Compose (MonoidalMap x)) (Compose (MonoidalMap y)) -> fmap Compose $ nothingOnNull $ MonoidalMap $ mergeMapSemigroup x y) xs ys
Expand All @@ -82,7 +83,7 @@ instance (Ord k1, Ord k2, Monoid g, Eq g) => Monoid (MapV k1 v (Compose (Monoida

instance (Ord k1, Ord k2, Group g, Eq g) => Group (MapV k1 v (Compose (MonoidalMap k2) (Const g))) where
negateG (MapV xs) = MapV $ fmap negateG xs
instance (Ord k1, Ord k2, Additive g, Group g, Eq g) => Additive (MapV k1 v (Compose (MonoidalMap k2) (Const g)))
instance (Ord k1, Ord k2, Commutative g, Group g, Eq g) => Commutative (MapV k1 v (Compose (MonoidalMap k2) (Const g)))

instance (Ord k) => View (MapV k v) where
cropV f (MapV s) (MapV i) = collapseNullV $ MapV (Map.intersectionWithKey (\_ x y -> f x y) s i)
Expand Down
1 change: 0 additions & 1 deletion src/Data/Vessel/Selectable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ class Selectable v k where
selector :: (forall a. p a) -> k -> v p
-- | From a view, extract a more convenient type of value to use.
selection :: k -> v Identity -> Selection v k

17 changes: 9 additions & 8 deletions src/Data/Vessel/Single.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@

module Data.Vessel.Single where

import Data.These
import Data.Patch (Group(..), Additive)
import Data.Semigroup
import Data.Functor.Identity
import Data.Witherable
import Data.Aeson
import Data.Align
import Data.Functor.Compose
import Data.Functor.Const
import Data.Align
import Data.Aeson
import Data.Functor.Identity
import Data.Patch (Group(..))
import Data.Semigroup
import Data.Semigroup.Commutative
import Data.These
import GHC.Generics (Generic)
import Witherable

import Data.Vessel.Class
import Data.Vessel.Selectable
Expand All @@ -56,7 +57,7 @@ instance (Monoid (g (First (Maybe a)))) => Monoid (SingleV a g) where
instance (Group (g (First (Maybe a)))) => Group (SingleV a g) where
negateG (SingleV x) = SingleV (negateG x)

instance (Additive (g (First (Maybe a)))) => Additive (SingleV a g)
instance (Commutative (g (First (Maybe a)))) => Commutative (SingleV a g)

instance View (SingleV a) where
cropV f (SingleV s) (SingleV i) = Just $ SingleV $ f s i
Expand Down
18 changes: 9 additions & 9 deletions src/Data/Vessel/SubVessel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,30 @@ import Control.Applicative
import Data.Aeson
import Data.Constraint
import Data.Constraint.Extras
import qualified Data.Dependent.Map as DMap'
import Data.Dependent.Map.Monoidal (MonoidalDMap(..))
import qualified Data.Dependent.Map.Monoidal as DMap
import Data.Dependent.Sum (DSum(..))
import Data.Foldable
import Data.Functor.Compose
import Data.Functor.Identity
import Data.GADT.Compare
import Data.GADT.Show
import Data.Map.Monoidal (MonoidalMap(..))
import qualified Data.Map.Monoidal as Map
import Data.Orphans ()
import Data.Patch (Group(..))
import Data.Proxy
import Data.Semigroup.Commutative
import Data.Set (Set)
import Data.Some (Some(Some))
import Data.Type.Equality
import GHC.Generics
import Data.Patch (Group(..), Additive)
import Reflex.Query.Class
import qualified Data.Dependent.Map as DMap'
import qualified Data.Dependent.Map.Monoidal as DMap
import qualified Data.Map.Monoidal as Map

import Data.Vessel.Class hiding (empty)
import Data.Vessel.Vessel
import Data.Vessel.Internal
import Data.Vessel.Vessel
import Data.Vessel.ViewMorphism

data SubVesselKey k (f :: (* -> *) -> *) (g :: (* -> *) -> *) where
Expand All @@ -56,8 +58,7 @@ instance Show k => GShow (SubVesselKey k f) where gshowsPrec = showsPrec
instance FromJSON k => FromJSON (Some (SubVesselKey k v)) where parseJSON v = Some . SubVesselKey <$> parseJSON v
instance ToJSON k => ToJSON (SubVesselKey k f g) where toJSON (SubVesselKey k) = toJSON k

instance ArgDict c (SubVesselKey k f) where
type ConstraintsFor (SubVesselKey k f) c = c f
instance (c f) => Has c (SubVesselKey k f) where
argDict (SubVesselKey _) = Dict

instance Eq k => GEq (SubVesselKey k v) where
Expand All @@ -76,7 +77,7 @@ instance Ord k => GCompare (SubVesselKey k v) where
-- TODO: this representation has the advantage that all of it's instances come "free", but the mostly "right" representation is probably
-- ... Vessel v (Compose (MonoidalMap k) f)
newtype SubVessel (k :: *) (v :: (* -> *) -> *) (f :: * -> *) = SubVessel { unSubVessel :: Vessel (SubVesselKey k v) f }
deriving (FromJSON, ToJSON, Semigroup, Monoid, Generic, Group, Additive, Eq)
deriving (FromJSON, ToJSON, Semigroup, Monoid, Generic, Group, Commutative, Eq)

deriving instance (Show k, Show (v f)) => Show (SubVessel k v f)

Expand Down Expand Up @@ -244,4 +245,3 @@ handleSubSubVesselSelector f xs = currySubVessel <$> handleSubVesselSelector f (

instance (Ord k, View v) => EmptyView (SubVessel k v) where
emptyV = SubVessel emptyV

Loading

0 comments on commit 3c48555

Please sign in to comment.