on 2a4fec2 help sign in
36 lines 1.1 kB history raw
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 #-}
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-- Provides an (orphan) IsLabel instance for field lenses.
21-- Use at your own risk.
22--------------------------------------------------------------------------------
24module Data.Generics.Labels () where
26import Data.Generics.Product
27import GHC.OverloadedLabels
30instance (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