@@ -0,0 +1,36 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE MultiParamTypeClasses #-}
4+{-# LANGUAGE ScopedTypeVariables #-}
5+{-# LANGUAGE TypeApplications #-}
6+{-# LANGUAGE TypeFamilies #-}
7+{-# LANGUAGE UndecidableInstances #-}
8+{-# OPTIONS_GHC -Wno-orphans #-}
9+
10+
11+--------------------------------------------------------------------------------
12+-- |
13+-- Module : Data.Generics.Labels
14+-- Copyright : (C) 2017 Csongor Kiss
15+-- Maintainer : Csongor Kiss <kiss.csongor.kiss@gmail.com>
16+-- License : BSD3
17+-- Stability : experimental
18+-- Portability : non-portable
19+--
20+-- Provide an (orphan) IsLabel instance for field lenses
21+--
22+--------------------------------------------------------------------------------
23+
24+module Data.Generics.Labels () where
25+
26+import Data.Generics.Product
27+import GHC.OverloadedLabels
28+
29+
30+instance (HasField field s t a b, Functor f, sft ~ (s -> f t)) =>
31+ IsLabel field ((a -> f b) -> sft) where
32+#if __GLASGOW_HASKELL__ >= 802
33+ fromLabel = field @field
34+#else
35+ fromLabel _ = field @field
36+#endif