generic-lens-labels (empty) → 0.1.0.1
raw patch · 5 files changed
+135/−0 lines, 5 filesdep +basedep +generic-lenssetup-changed
Dependencies added: base, generic-lens
Files
- ChangeLog.md +5/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- generic-lens-labels.cabal +41/−0
- src/Data/Generics/Labels.hs +57/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for generic-lens-labels++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2017, Douglas Wilson++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Douglas Wilson nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ generic-lens-labels.cabal view
@@ -0,0 +1,41 @@+-- Initial generic-lens-labels.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: generic-lens-labels+version: 0.1.0.1++synopsis: GHC.OverloadedLabels.IsLabel instance for lenses from ghc-generics+description:+ Provides an orphan GHC.OverloadedLabels.IsLabel instance for lenses from+ ghc-generics. All effort is taken to play as nicely as possible with other+ IsLabel instances -- however orphan instances are inherently problematic.+ Please do not depend on this package from any hackage libraries.+category: Generics, Records, Lens, OverloadeLabels++copyright: Copyright (C) 2017-2018 Douglas Wilson+license: BSD3+license-file: LICENSE++author: Douglas Wilson+maintainer: douglas.wilson@gmail.com+homepage: https://github.com/duog/generic-lens-labels+bug-reports: http://github.com/ekmett/lens/issues++build-type: Simple+cabal-version: >= 1.10++-- TODO+tested-With: GHC == 8.0.2, GHC == 8.2.2++build-type: Simple+extra-source-files: ChangeLog.md+cabal-version: >=1.10++library+ exposed-modules: Data.Generics.Labels+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.9 && <4.11,+ generic-lens >= 0.3.0 && < 0.5.2+ hs-source-dirs: src+ default-language: Haskell2010
+ src/Data/Generics/Labels.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE CPP, TypeFamilies, TypeApplications,ScopedTypeVariables+ , FlexibleInstances, MultiParamTypeClasses, UndecidableInstances #-}+{-# OPTIONS_GHC -Wno-orphans #-}+module Data.Generics.Labels+ () where++import Data.Generics.Product+import GHC.OverloadedLabels++{-+example:++data Foo = Foo {bar :: Int} deriving (Generic)++_bar :: Lens' Foo Int+_bar = #bar++-}++{-+This is the instance head that seems to give the best type inference.+-}++#if MIN_VERSION_generic_lens(0,5,0)++#if (__GLASGOW_HASKELL__ < 802)++instance (HasField x s t a b, Functor f, lens ~ ((a -> f b) -> s -> f t)) =>+ IsLabel x lens where+ fromLabel _ = field @ x++#else+-- __GLASGOW_HASKELL++instance (HasField x s t a b, Functor f, lens ~ ((a -> f b) -> s -> f t)) =>+ IsLabel x lens where+ fromLabel = field @ x++#endif+-- __GLASGOW_HASKELL++#elif (__GLASGOW_HASKELL__ < 802)+-- MIN_VERSION_generic_lens++instance (HasField x a s, Functor f, lens ~ ((a -> f a) -> s -> f s)) =>+ IsLabel x lens where+ fromLabel _ = field @ x++#else+-- __GLASGOW_HASKELL++instance (HasField x a s, Functor f, lens ~ ((a -> f a) -> s -> f s)) =>+ IsLabel x lens where+ fromLabel = field @ x++#endif+-- __GLASGOW_HASKELL