horizon-spec-lens (empty) → 0.1
raw patch · 5 files changed
+160/−0 lines, 5 filesdep +basedep +horizon-specdep +lens
Dependencies added: base, horizon-spec, lens
Files
- ChangeLog.md +16/−0
- LICENSE +19/−0
- README.md +17/−0
- horizon-spec-lens.cabal +48/−0
- src/Horizon/Spec/Lens.hs +60/−0
+ ChangeLog.md view
@@ -0,0 +1,16 @@+# Changelog for horizon-spec-lens++## 0.1++* lens classes and instances for `horizon-spec-0.6.*`.+* Add `HasPackageSet` class.+* Add `HasPackages` class.+* Add `HasPackageSet` instances for `Overlay`,+ `PackageSetExportSettings`, `OverlayExportSettings`,+ `HorizonExport`.+* Add `HasPackages` instances for `Overlay`,+ `PackageSetExportSettings`, `OverlayExportSettings`,+ `HorizonExport`.+* Add `Ixed` and `At` instances for `PackageList`, `Overlay`,+ `PackageSetExportSettings`, `OverlayExportSettings`,+ `HorizonExport`.
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright 2022 Homotopic.Tech Ltd++Permission is hereby granted, free of charge, to any person obtaining a copy of+this software and associated documentation files (the "Software"), to deal in+the Software without restriction, including without limitation the rights to+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies+of the Software, and to permit persons to whom the Software is furnished to do+so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ README.md view
@@ -0,0 +1,17 @@+# horizon-spec-lens++horizon-spec-lens contains lenses for +[horizon-spec](https://gitlab.homotopic.tech/horizon/horizon-spec).++## Building++```+nix build+```++## Development++```+nix develop+cabal test all+```
+ horizon-spec-lens.cabal view
@@ -0,0 +1,48 @@+cabal-version: 3.0+name: horizon-spec-lens+version: 0.1+synopsis: Horizon Stable Package Set Lenses+description:+ This package contains the lenses for the Horizon stable package set types (https://horizon-haskell.net). This is a schema used to define package sets sourcing from hackage and git.++category: Package Management+author: Daniel Firth+maintainer: dan.firth@homotopic.tech+copyright: 2022 Daniel Firth+homepage: https://horizon-haskell.net+license: MIT+license-file: LICENSE+build-type: Simple+extra-source-files:+ ChangeLog.md+ README.md++source-repository head+ type: git+ location: https://gitlab.homotopic.tech/horizon/horizon-spec-lens++library+ exposed-modules: Horizon.Spec.Lens+ hs-source-dirs: src+ default-extensions:+ DataKinds+ DeriveGeneric+ DerivingStrategies+ GADTs+ GeneralizedNewtypeDeriving+ LambdaCase+ StandaloneKindSignatures+ TypeApplications+ TypeFamilies++ ghc-options:+ -Weverything -Wno-all-missed-specialisations -Wno-implicit-prelude+ -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module+ -Wno-safe -Wno-unsafe++ build-depends:+ , base >=4.7 && <5+ , horizon-spec >=0.6 && <0.7+ , lens >=5.0 && <5.3++ default-language: Haskell2010
+ src/Horizon/Spec/Lens.hs view
@@ -0,0 +1,60 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Horizon.Spec.Lens (HasPackageSet, HasPackages) where++import Control.Lens as L (At, Index, IxValue, Ixed, Lens', at, ix,+ lens)+import Data.Kind (Constraint, Type)+import Horizon.Spec (HaskellPackage,+ HorizonExport (MakeOverlay, MakePackageSet),+ Name, Overlay (MkOverlay), OverlayExportSettings,+ PackageList (MkPackageList), PackageSet,+ PackageSetExportSettings, fromOverlay, overlay,+ packageSet, packages)++type HasPackageSet :: Type -> Constraint+class HasPackageSet x where+ packageSetL :: L.Lens' x PackageSet++instance HasPackageSet Overlay where+ packageSetL = L.lens fromOverlay (\(MkOverlay _) ys -> MkOverlay ys)++instance HasPackageSet PackageSetExportSettings where+ packageSetL = L.lens packageSet (\x y -> x { packageSet = y })++instance HasPackageSet OverlayExportSettings where+ packageSetL = L.lens overlay (\x y -> x { overlay = y }) . packageSetL @Overlay++instance HasPackageSet HorizonExport where+ packageSetL f = \case+ MakePackageSet x -> MakePackageSet <$> packageSetL f x+ MakeOverlay x -> MakeOverlay <$> packageSetL f x++type HasPackages :: Type -> Constraint+class HasPackages x where+ packagesL :: L.Lens' x PackageList++instance HasPackages PackageSet where+ packagesL = L.lens packages (\x y -> x { packages = y })++instance HasPackages HorizonExport where+ packagesL = packageSetL . packagesL @PackageSet++type instance L.IxValue PackageList = HaskellPackage++type instance L.Index PackageList = Name++type instance L.IxValue HorizonExport = HaskellPackage++type instance L.Index HorizonExport = Name++instance L.Ixed PackageList where+ ix k f (MkPackageList xs) = MkPackageList <$> L.ix k f xs++instance L.At PackageList where+ at k f (MkPackageList xs) = MkPackageList <$> L.at k f xs++instance L.Ixed HorizonExport where+ ix k = packagesL @HorizonExport . L.ix @PackageList k++instance L.At HorizonExport where+ at k = packagesL @HorizonExport . L.at @PackageList k