-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Multidimensional grids with sized specified at compile time -- -- `size-grid` allows you to make finite sized grids and have their size -- and shape confirmed at compile time -- -- Consult the readme for a short tutorial and explanation. @package sized-grid @version 0.2.0.1 module SizedGrid.Ordinal -- | An Ordinal can only hold m different values, ususally corresponding to -- 0 .. m - 1. We store it here using a Proxy of a type level -- number and use constraints to keep the required invariants. -- -- Desprite represeting a number, Ordinal is not an instance of Num and -- many functions (such as negate) would only be partial data Ordinal m [Ordinal] :: (KnownNat n, KnownNat m, ((n + 1) <=? m) ~ 'True) => Proxy n -> Ordinal m -- | Convert a normal integral to an ordinal. If it is outside the range -- (or= m), Nothing is returned. numToOrdinal :: forall a m. (KnownNat m, Integral a) => a -> Maybe (Ordinal m) -- | Transform an ordinal to a given number ordinalToNum :: Num a => Ordinal m -> a strengthenOrdinal :: forall n m. (KnownNat m, n <= m) => Ordinal n -> Ordinal m weakenOrdinal :: KnownNat m => Ordinal n -> Maybe (Ordinal m) -- | Convert between an ordinal and a usual number. This is a -- Prism as it may fail as Oridnals can only exist in a -- certain range. _Ordinal :: (KnownNat n, Integral a) => Prism' a (Ordinal n) instance GHC.Show.Show (SizedGrid.Ordinal.Ordinal m) instance GHC.Classes.Eq (SizedGrid.Ordinal.Ordinal m) instance GHC.Classes.Ord (SizedGrid.Ordinal.Ordinal m) instance (1 GHC.TypeNats.<= m, GHC.TypeNats.KnownNat m) => System.Random.Random (SizedGrid.Ordinal.Ordinal m) instance (1 GHC.TypeNats.<= m, GHC.TypeNats.KnownNat m) => GHC.Enum.Bounded (SizedGrid.Ordinal.Ordinal m) instance (1 GHC.TypeNats.<= m, GHC.TypeNats.KnownNat m) => GHC.Enum.Enum (SizedGrid.Ordinal.Ordinal m) instance GHC.TypeNats.KnownNat m => Data.Aeson.Types.ToJSON.ToJSON (SizedGrid.Ordinal.Ordinal m) instance GHC.TypeNats.KnownNat m => Data.Aeson.Types.FromJSON.FromJSON (SizedGrid.Ordinal.Ordinal m) instance GHC.TypeNats.KnownNat m => Data.Aeson.Types.ToJSON.ToJSONKey (SizedGrid.Ordinal.Ordinal m) instance GHC.TypeNats.KnownNat m => Data.Aeson.Types.FromJSON.FromJSONKey (SizedGrid.Ordinal.Ordinal m) module SizedGrid.Coord.Class -- | Everything that can be uses as a Coordinate. The only required -- function is asOrdinal and the type instance of -- CoordSized: the rest can be derived automatically. class IsCoord (c :: Nat -> *) -- | As each coord represents a finite number of states, it must be -- isomorphic to an Ordinal asOrdinal :: IsCoord c => Iso' (c n) (Ordinal n) -- | The origin. If c is an instance of Monoid, this should be -- mempty zeroPosition :: (IsCoord c, 1 <= n, KnownNat n) => c n -- | The origin. If c is an instance of Monoid, this should be -- mempty zeroPosition :: (IsCoord c, Monoid (c n)) => c n -- | Retrive a Proxy of the size sCoordSized :: IsCoord c => Proxy (c n) -> Proxy n -- | The largest possible number expressable maxCoordSize :: (IsCoord c, KnownNat n) => Proxy (c n) -> Integer -- | The maximum value of a coord maxCoord :: (IsCoord c, KnownNat n) => Proxy n -> c n asSizeProxy :: IsCoord c => c n -> (forall m. (KnownNat m, (m + 1) <= n) => Proxy m -> x) -> x weakenIsCoord :: (IsCoord c, KnownNat m) => c n -> Maybe (c m) strengthenIsCoord :: (IsCoord c, KnownNat m, n <= m) => c n -> c m -- | Sometimes it useful to work with Coords of type *, not Nat -> *. -- This is away of doing so. | | It should be autogenerated for all valid -- instances of IsCoord class (x ~ ((CoordContainer x) (CoordNat x)), 1 <= CoordNat x, IsCoord (CoordContainer x), KnownNat (CoordNat x)) => IsCoordLifted x where { type family CoordContainer x :: Nat -> *; type family CoordNat x :: Nat; } -- | Enumerate all possible values of a coord, in order allCoordLike :: (1 <= n, IsCoord c, KnownNat n) => [c n] instance (GHC.TypeNats.KnownNat n, 1 GHC.TypeNats.<= n, SizedGrid.Coord.Class.IsCoord c) => SizedGrid.Coord.Class.IsCoordLifted (c n) instance SizedGrid.Coord.Class.IsCoord SizedGrid.Ordinal.Ordinal module SizedGrid.Coord.Periodic -- | A coordinate with periodic boundaries, as if on a taurus newtype Periodic (n :: Nat) Periodic :: Ordinal n -> Periodic [unPeriodic] :: Periodic -> Ordinal n instance GHC.Classes.Ord (SizedGrid.Coord.Periodic.Periodic n) instance GHC.Show.Show (SizedGrid.Coord.Periodic.Periodic n) instance GHC.Classes.Eq (SizedGrid.Coord.Periodic.Periodic n) instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => System.Random.Random (SizedGrid.Coord.Periodic.Periodic n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.ToJSON.ToJSON (SizedGrid.Coord.Periodic.Periodic n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.ToJSON.ToJSONKey (SizedGrid.Coord.Periodic.Periodic n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.FromJSON.FromJSON (SizedGrid.Coord.Periodic.Periodic n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.FromJSON.FromJSONKey (SizedGrid.Coord.Periodic.Periodic n) instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => GHC.Enum.Enum (SizedGrid.Coord.Periodic.Periodic n) instance SizedGrid.Coord.Class.IsCoord SizedGrid.Coord.Periodic.Periodic instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => GHC.Base.Semigroup (SizedGrid.Coord.Periodic.Periodic n) instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => GHC.Base.Monoid (SizedGrid.Coord.Periodic.Periodic n) instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => Data.AdditiveGroup.AdditiveGroup (SizedGrid.Coord.Periodic.Periodic n) instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => Data.AffineSpace.AffineSpace (SizedGrid.Coord.Periodic.Periodic n) module SizedGrid.Coord.HardWrap -- | A coordinate that clamps its numbers newtype HardWrap (n :: Nat) HardWrap :: Ordinal n -> HardWrap [unHardWrap] :: HardWrap -> Ordinal n instance GHC.Classes.Ord (SizedGrid.Coord.HardWrap.HardWrap n) instance GHC.Show.Show (SizedGrid.Coord.HardWrap.HardWrap n) instance GHC.Classes.Eq (SizedGrid.Coord.HardWrap.HardWrap n) instance (GHC.TypeNats.KnownNat n, 1 GHC.TypeNats.<= n) => System.Random.Random (SizedGrid.Coord.HardWrap.HardWrap n) instance (GHC.TypeNats.KnownNat n, 1 GHC.TypeNats.<= n) => GHC.Enum.Enum (SizedGrid.Coord.HardWrap.HardWrap n) instance (GHC.TypeNats.KnownNat n, 1 GHC.TypeNats.<= n) => GHC.Enum.Bounded (SizedGrid.Coord.HardWrap.HardWrap n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.ToJSON.ToJSON (SizedGrid.Coord.HardWrap.HardWrap n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.FromJSON.FromJSON (SizedGrid.Coord.HardWrap.HardWrap n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.ToJSON.ToJSONKey (SizedGrid.Coord.HardWrap.HardWrap n) instance GHC.TypeNats.KnownNat n => Data.Aeson.Types.FromJSON.FromJSONKey (SizedGrid.Coord.HardWrap.HardWrap n) instance SizedGrid.Coord.Class.IsCoord SizedGrid.Coord.HardWrap.HardWrap instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => GHC.Base.Semigroup (SizedGrid.Coord.HardWrap.HardWrap n) instance (GHC.TypeNats.KnownNat n, 1 GHC.TypeNats.<= n) => GHC.Base.Monoid (SizedGrid.Coord.HardWrap.HardWrap n) instance (1 GHC.TypeNats.<= n, GHC.TypeNats.KnownNat n) => Data.AffineSpace.AffineSpace (SizedGrid.Coord.HardWrap.HardWrap n) module SizedGrid.Coord -- | Length of a type level list type family Length cs -- | A multideminsion coordinate newtype Coord cs Coord :: NP I cs -> Coord cs [unCoord] :: Coord cs -> NP I cs coordSplit :: Coord (c : cs) -> (c, Coord cs) pattern (:|) :: c -> Coord cs -> Coord (c : cs) infixr 5 :| pattern EmptyCoord :: Coord '[] _WrappedCoord :: Iso' (Coord cs) (NP I cs) -- | Get the first element of a coord. Thanks to type level information, we -- can write this as a total Lens coordHead :: Lens (Coord (a : as)) (Coord (a' : as)) a a' -- | A Lens into the the tail of Coord coordTail :: Lens (Coord (a : as)) (Coord (a : as')) (Coord as) (Coord as') -- | Turn a single element into a one dimensional Coord singleCoord :: a -> Coord '[a] -- | Add a new element to a Coord. This increases the dimensionality appendCoord :: a -> Coord as -> Coord (a : as) -- | The type of difference between two coords. A n-dimensional coord -- should have a Diff of an n-tuple of Integers. We use -- Identity and our 1-tuple. Unfortuantly, each instance is manual -- at the moment. type family CoordDiff (cs :: [k]) :: * -- | Apply Diff to each element of a type level list. This is -- required as type families can't be partially applied. type family MapDiff xs -- | Generate all possible coords in order allCoord :: forall cs. All IsCoordLifted cs => [Coord cs] -- | The number of elements a coord can have. This is equal to the product -- of the CoordSized of each element type family MaxCoordSize (cs :: [k]) :: Nat -- | Convert a Coord to its position in a vector coordPosition :: All IsCoordLifted cs => Coord cs -> Int -- | All Diffs of the members of the list must be equal type family AllDiffSame a xs :: Constraint -- | Calculate the Moore neighbourhood around a point. Includes the center moorePoints :: forall a cs. (Enum a, Num a, AllDiffSame a cs, All AffineSpace cs) => a -> Coord cs -> [Coord cs] -- | Calculate the von Neuman neighbourhood around a point. Includes the -- center vonNeumanPoints :: forall a cs. (Enum a, Num a, Ord a, All Integral (MapDiff cs), AllDiffSame a cs, All AffineSpace cs, Ord (CoordDiff cs), IsProductType (CoordDiff cs) (MapDiff cs), AdditiveGroup (CoordDiff cs)) => a -> Coord cs -> [Coord cs] -- | Swap x and y for a coord in 2D space tranposeCoord :: Coord '[a, b] -> Coord '[b, a] -- | The zero position for a coord zeroCoord :: All IsCoordLifted cs => Coord cs class AllSizedKnown (cs :: [*]) sizeProof :: AllSizedKnown cs => Dict (KnownNat (MaxCoordSize cs)) class WeakenCoord as bs weakenCoord :: WeakenCoord as bs => Coord as -> Maybe (Coord bs) class StrengthenCoord as bs strengthenCoord :: StrengthenCoord as bs => Coord as -> Coord bs instance GHC.Generics.Generic (SizedGrid.Coord.Coord cs) instance SizedGrid.Coord.StrengthenCoord '[] '[] instance (SizedGrid.Coord.StrengthenCoord as bs, SizedGrid.Coord.Class.IsCoord c, n GHC.TypeNats.<= m, GHC.TypeNats.KnownNat m) => SizedGrid.Coord.StrengthenCoord (c n : as) (c m : bs) instance SizedGrid.Coord.WeakenCoord '[] '[] instance (SizedGrid.Coord.WeakenCoord as bs, SizedGrid.Coord.Class.IsCoord c, GHC.TypeNats.KnownNat m) => SizedGrid.Coord.WeakenCoord (c n : as) (c m : bs) instance SizedGrid.Coord.AllSizedKnown '[] instance (GHC.TypeNats.KnownNat n, SizedGrid.Coord.AllSizedKnown as) => SizedGrid.Coord.AllSizedKnown (c n : as) instance (Data.SOP.Constraint.All Data.AffineSpace.AffineSpace cs, Data.AdditiveGroup.AdditiveGroup (SizedGrid.Coord.CoordDiff cs), Generics.SOP.Universe.IsProductType (SizedGrid.Coord.CoordDiff cs) (SizedGrid.Coord.MapDiff cs)) => Data.AffineSpace.AffineSpace (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All GHC.Classes.Eq cs => GHC.Classes.Eq (SizedGrid.Coord.Coord cs) instance (Data.SOP.Constraint.All GHC.Classes.Eq cs, Data.SOP.Constraint.All GHC.Classes.Ord cs) => GHC.Classes.Ord (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All GHC.Show.Show cs => GHC.Show.Show (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All Data.Aeson.Types.ToJSON.ToJSON cs => Data.Aeson.Types.ToJSON.ToJSON (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All Data.Aeson.Types.FromJSON.FromJSON cs => Data.Aeson.Types.FromJSON.FromJSON (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All GHC.Base.Semigroup cs => GHC.Base.Semigroup (SizedGrid.Coord.Coord cs) instance (Data.SOP.Constraint.All GHC.Base.Semigroup cs, Data.SOP.Constraint.All GHC.Base.Monoid cs) => GHC.Base.Monoid (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All Data.AdditiveGroup.AdditiveGroup cs => Data.AdditiveGroup.AdditiveGroup (SizedGrid.Coord.Coord cs) instance Data.SOP.Constraint.All System.Random.Random cs => System.Random.Random (SizedGrid.Coord.Coord cs) instance Control.Lens.Tuple.Field1 (SizedGrid.Coord.Coord (a : cs)) (SizedGrid.Coord.Coord (a' : cs)) a a' instance Control.Lens.Tuple.Field2 (SizedGrid.Coord.Coord (a : b : cs)) (SizedGrid.Coord.Coord (a : b' : cs)) b b' instance Control.Lens.Tuple.Field3 (SizedGrid.Coord.Coord (a : b : c : cs)) (SizedGrid.Coord.Coord (a : b : c' : cs)) c c' instance Control.Lens.Tuple.Field4 (SizedGrid.Coord.Coord (a : b : c : d : cs)) (SizedGrid.Coord.Coord (a : b : c : d' : cs)) d d' instance Control.Lens.Tuple.Field5 (SizedGrid.Coord.Coord (a : b : c : d : e : cs)) (SizedGrid.Coord.Coord (a : b : c : d : e' : cs)) e e' module SizedGrid.Grid.Grid -- | A multi dimensional sized grid newtype Grid (cs :: [*]) a Grid :: Vector a -> Grid a [unGrid] :: Grid a -> Vector a -- | The first element of a type level list type family Head xs -- | All but the first elements of a type level list type family Tail xs -- | Given a grid type, give back a series of nested lists repesenting the -- grid. The lists will have a number of layers equal to the -- dimensionality. type family CollapseGrid cs a -- | A Constraint that all grid sizes are instances of KnownNat type family AllGridSizeKnown cs :: Constraint -- | Convert a vector into a list of Vectors, where all the -- elements of the list have the given size. splitVectorBySize :: Int -> Vector a -> [Vector a] -- | Convert a grid to a series of nested lists. This removes type level -- information, but it is sometimes easier to work with lists collapseGrid :: forall cs a. (SListI cs, AllGridSizeKnown cs) => Grid cs a -> CollapseGrid cs a -- | Convert a series of nested lists to a grid. If the size of the grid -- does not match the size of lists this will be Nothing gridFromList :: forall cs a. (SListI cs, AllGridSizeKnown cs) => CollapseGrid cs a -> Maybe (Grid cs a) transposeGrid :: (IsCoord h, IsCoord w, KnownNat x, KnownNat y, 1 <= y, 1 <= x) => Grid '[w x, h y] a -> Grid '[h y, w x] a splitGrid :: forall c cs a. AllSizedKnown cs => Grid (c : cs) a -> Grid '[c] (Grid cs a) combineGrid :: Grid '[c] (Grid cs a) -> Grid (c : cs) a combineHigherDim :: IsCoord c => Grid (c n : as) x -> Grid (c m : as) x -> Grid (c (n + m) : as) x dropGrid :: KnownNat n => Proxy n -> Grid '[c m] x -> Grid '[c (m - n)] x takeGrid :: KnownNat n => Proxy n -> Grid '[c m] x -> Grid '[c n] x splitHigherDim :: forall c as x y z a. (KnownNat x, KnownNat y, y <= x, AllSizedKnown as, IsCoord c) => Grid (c x : as) a -> (Grid (c y : as) a, Grid (c z : as) a) mapLowerDim :: forall as bs x y c f. (AllSizedKnown as, Applicative f) => (Grid as x -> f (Grid bs y)) -> Grid (c : as) x -> f (Grid (c : bs) y) class ShrinkableGrid (cs :: [*]) (as :: [*]) (bs :: [*]) shrinkGrid :: ShrinkableGrid cs as bs => Coord cs -> Grid as x -> Grid bs x instance GHC.Generics.Generic (SizedGrid.Grid.Grid.Grid cs a) instance Data.Functor.Classes.Show1 (SizedGrid.Grid.Grid.Grid cs) instance Data.Functor.Classes.Eq1 (SizedGrid.Grid.Grid.Grid cs) instance Data.Traversable.Traversable (SizedGrid.Grid.Grid.Grid cs) instance Data.Foldable.Foldable (SizedGrid.Grid.Grid.Grid cs) instance GHC.Base.Functor (SizedGrid.Grid.Grid.Grid cs) instance GHC.Show.Show a => GHC.Show.Show (SizedGrid.Grid.Grid.Grid cs a) instance GHC.Classes.Eq a => GHC.Classes.Eq (SizedGrid.Grid.Grid.Grid cs a) instance SizedGrid.Grid.Grid.ShrinkableGrid '[] '[] '[] instance (GHC.TypeNats.KnownNat z, SizedGrid.Coord.AllSizedKnown as, SizedGrid.Coord.Class.IsCoord c, SizedGrid.Grid.Grid.ShrinkableGrid cs as bs, z GHC.TypeNats.<= ((x GHC.TypeNats.- y) GHC.TypeNats.+ 1)) => SizedGrid.Grid.Grid.ShrinkableGrid (c x : cs) (c y : as) (c z : bs) instance (SizedGrid.Grid.Grid.AllGridSizeKnown cs, Data.Aeson.Types.ToJSON.ToJSON a, Data.SOP.Constraint.SListI cs) => Data.Aeson.Types.ToJSON.ToJSON (SizedGrid.Grid.Grid.Grid cs a) instance (Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs, Data.Aeson.Types.FromJSON.FromJSON a) => Data.Aeson.Types.FromJSON.FromJSON (SizedGrid.Grid.Grid.Grid cs a) instance SizedGrid.Coord.AllSizedKnown cs => GHC.Base.Applicative (SizedGrid.Grid.Grid.Grid cs) instance (SizedGrid.Coord.AllSizedKnown cs, Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs) => GHC.Base.Monad (SizedGrid.Grid.Grid.Grid cs) instance (SizedGrid.Coord.AllSizedKnown cs, Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs) => Data.Distributive.Distributive (SizedGrid.Grid.Grid.Grid cs) instance (Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs, SizedGrid.Coord.AllSizedKnown cs) => Data.Functor.Rep.Representable (SizedGrid.Grid.Grid.Grid cs) instance Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs => Control.Lens.Indexed.FunctorWithIndex (SizedGrid.Coord.Coord cs) (SizedGrid.Grid.Grid.Grid cs) instance Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs => Control.Lens.Indexed.FoldableWithIndex (SizedGrid.Coord.Coord cs) (SizedGrid.Grid.Grid.Grid cs) instance Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs => Control.Lens.Indexed.TraversableWithIndex (SizedGrid.Coord.Coord cs) (SizedGrid.Grid.Grid.Grid cs) module SizedGrid.Grid.Focused -- | Similar to Grid, but this has a focus on a certain square. -- Becuase of this we loose some instances, such as Applicative, -- but we gain a Comonad and ComonadStore instance. We can -- convert between a focused and unfocused list using facilites in -- IsGrid data FocusedGrid cs a FocusedGrid :: Grid cs a -> Coord cs -> FocusedGrid cs a [focusedGrid] :: FocusedGrid cs a -> Grid cs a [focusedGridPosition] :: FocusedGrid cs a -> Coord cs instance Data.Traversable.Traversable (SizedGrid.Grid.Focused.FocusedGrid cs) instance Data.Foldable.Foldable (SizedGrid.Grid.Focused.FocusedGrid cs) instance GHC.Base.Functor (SizedGrid.Grid.Focused.FocusedGrid cs) instance (SizedGrid.Coord.AllSizedKnown cs, Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs, Data.SOP.Constraint.All GHC.Base.Monoid cs, Data.SOP.Constraint.All GHC.Base.Semigroup cs, Data.SOP.Constraint.SListI cs) => Control.Comonad.Comonad (SizedGrid.Grid.Focused.FocusedGrid cs) instance (SizedGrid.Coord.AllSizedKnown cs, Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs, Data.SOP.Constraint.All GHC.Base.Monoid cs, Data.SOP.Constraint.All GHC.Base.Semigroup cs, Data.SOP.Constraint.SListI cs) => Control.Comonad.Store.Class.ComonadStore (SizedGrid.Coord.Coord cs) (SizedGrid.Grid.Focused.FocusedGrid cs) module SizedGrid.Grid.Class -- | Conversion between Grid and FocusedGrid and access grids -- at a Coord class IsGrid cs grid | grid -> cs -- | Get the element at a grid location. This is a lens because we know it -- must exist gridIndex :: IsGrid cs grid => Coord cs -> Lens' (grid a) a -- | Convert to, or run a function over, a Grid asGrid :: IsGrid cs grid => Lens' (grid a) (Grid cs a) -- | Convert to, or run a function over, a FocusedGrid asFocusedGrid :: IsGrid cs grid => Lens' (grid a) (FocusedGrid cs a) instance (SizedGrid.Coord.AllSizedKnown cs, Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs) => SizedGrid.Grid.Class.IsGrid cs (SizedGrid.Grid.Grid.Grid cs) instance (SizedGrid.Coord.AllSizedKnown cs, Data.SOP.Constraint.All SizedGrid.Coord.Class.IsCoordLifted cs) => SizedGrid.Grid.Class.IsGrid cs (SizedGrid.Grid.Focused.FocusedGrid cs) module SizedGrid -- | Require a constraint for every element of a list. -- -- If you have a datatype that is indexed over a type-level list, then -- you can use All to indicate that all elements of that -- type-level list must satisfy a given constraint. -- -- Example: The constraint -- --
--   All Eq '[ Int, Bool, Char ]
--   
-- -- is equivalent to the constraint -- --
--   (Eq Int, Eq Bool, Eq Char)
--   
-- -- Example: A type signature such as -- --
--   f :: All Eq xs => NP I xs -> ...
--   
-- -- means that f can assume that all elements of the n-ary -- product satisfy Eq. -- -- Note on superclasses: ghc cannot deduce superclasses from All -- constraints. You might expect the following to compile -- --
--   class (Eq a) => MyClass a
--   
--   foo :: (All Eq xs) => NP f xs -> z
--   foo = [..]
--   
--   bar :: (All MyClass xs) => NP f xs -> x
--   bar = foo
--   
-- -- but it will fail with an error saying that it was unable to deduce the -- class constraint AllF Eq xs (or similar) in the -- definition of bar. In cases like this you can use Dict -- from Data.SOP.Dict to prove conversions between constraints. -- See this answer on SO for more details. class (AllF c xs, SListI xs) => All (c :: k -> Constraint) (xs :: [k]) -- | Implicit singleton list. -- -- A singleton list can be used to reveal the structure of a type-level -- list argument that the function is quantified over. -- -- Since 0.4.0.0, this is now defined in terms of All. A singleton -- list provides a witness for a type-level list where the elements need -- not satisfy any additional constraints. type SListI = All (Top :: k -> Constraint) -- | Composition of constraints. -- -- Note that the result of the composition must be a constraint, and -- therefore, in Compose f g, the kind of f is -- k -> Constraint. The kind of g, however, -- is l -> k and can thus be a normal type constructor. -- -- A typical use case is in connection with All on an NP or -- an NS. For example, in order to denote that all elements on an -- NP f xs satisfy Show, we can say All -- (Compose Show f) xs. class f g x => Compose (f :: k -> Constraint) (g :: k1 -> k) (x :: k1) infixr 9 `Compose` -- | The identity type functor. -- -- Like Identity, but with a shorter name. newtype I a I :: a -> I a