on master help sign in
Add missing module headers
fa94a03Csongor Kiss
README.md+1−1
@@ -200,7 +200,7 @@ error:
200 • The type Animal does not contain a constructor named "Giraffe"
200 • The type Animal does not contain a constructor named "Giraffe"
201```
201```
202
202
203−## Typed constructors
203+### Typed constructors
204
204
205Constructor components can be accessed using the component's type, assuming
205Constructor components can be accessed using the component's type, assuming
206that this type is unique:
206that this type is unique:
generic-lens.cabal+3−3
@@ -41,7 +41,7 @@ library
41
41
42 hs-source-dirs: src
42 hs-source-dirs: src
43 default-language: Haskell2010
43 default-language: Haskell2010
44− ghc-options: -Wall -Werror
44+ ghc-options: -Wall
45
45
46source-repository head
46source-repository head
47 type: git
47 type: git
@@ -58,7 +58,7 @@ test-suite generic-lens-test
58 , generic-lens
58 , generic-lens
59
59
60 default-language: Haskell2010
60 default-language: Haskell2010
61− ghc-options: -Wall -Werror
61+ ghc-options: -Wall
62
62
63benchmark generic-lens-bench
63benchmark generic-lens-bench
64 type: exitcode-stdio-1.0
64 type: exitcode-stdio-1.0
@@ -74,4 +74,4 @@ benchmark generic-lens-bench
74 , lens
74 , lens
75
75
76 default-language: Haskell2010
76 default-language: Haskell2010
77− ghc-options: -Wall -Werror
77+ ghc-options: -Wall
src/Data/Generics/Internal/Families.hs+10
@@ -1,3 +1,13 @@
1+-----------------------------------------------------------------------------
2+-- |
3+-- Module : Data.Generics.Internal.Families
4+-- Copyright : (C) 2017 Csongor Kiss
5+-- License : BSD3
6+-- Maintainer : Csongor Kiss <kiss.csongor.kiss@gmail.com>
7+-- Stability : experimental
8+-- Portability : non-portable
9+--
10+-----------------------------------------------------------------------------
1module Data.Generics.Internal.Families
11module Data.Generics.Internal.Families
2 ( module Families
12 ( module Families
3 ) where
13 ) where
src/Data/Generics/Internal/Families/Count.hs+10
@@ -4,6 +4,16 @@
4{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE TypeOperators #-}
5{-# LANGUAGE UndecidableInstances #-}
5{-# LANGUAGE UndecidableInstances #-}
6
6
7+-----------------------------------------------------------------------------
8+-- |
9+-- Module : Data.Generics.Internal.Families.Count
10+-- Copyright : (C) 2017 Csongor Kiss
11+-- License : BSD3
12+-- Maintainer : Csongor Kiss <kiss.csongor.kiss@gmail.com>
13+-- Stability : experimental
14+-- Portability : non-portable
15+--
16+-----------------------------------------------------------------------------
7module Data.Generics.Internal.Families.Count
17module Data.Generics.Internal.Families.Count
8 ( CountTotalType
18 ( CountTotalType
9 , CountPartialType
19 , CountPartialType
src/Data/Generics/Internal/Families/Has.hs+16−6
@@ -1,9 +1,19 @@
1−{-# LANGUAGE DataKinds #-}
1+{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE PolyKinds #-}
2+{-# LANGUAGE PolyKinds #-}
3−{-# LANGUAGE TypeFamilies #-}
3+{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
4+{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE UndecidableInstances #-}
5+{-# LANGUAGE UndecidableInstances #-}
6
6
7+-----------------------------------------------------------------------------
8+-- |
9+-- Module : Data.Generics.Internal.Families.Has
10+-- Copyright : (C) 2017 Csongor Kiss
11+-- License : BSD3
12+-- Maintainer : Csongor Kiss <kiss.csongor.kiss@gmail.com>
13+-- Stability : experimental
14+-- Portability : non-portable
15+--
16+-----------------------------------------------------------------------------
7module Data.Generics.Internal.Families.Has
17module Data.Generics.Internal.Families.Has
8 ( HasTotalFieldP
18 ( HasTotalFieldP
9 , HasTotalTypeP
19 , HasTotalTypeP
@@ -16,7 +26,7 @@ import GHC.Generics
16import GHC.TypeLits
26import GHC.TypeLits
17
27
18type family HasTotalFieldP (field :: Symbol) f :: Bool where
28type family HasTotalFieldP (field :: Symbol) f :: Bool where
19− HasTotalFieldP field (S1 ('MetaSel ('Just field) _ _ _) (Rec0 t))
29+ HasTotalFieldP field (S1 ('MetaSel ('Just field) _ _ _) _)
20 = 'True
30 = 'True
21 HasTotalFieldP field (l :*: r)
31 HasTotalFieldP field (l :*: r)
22 = HasTotalFieldP field l || HasTotalFieldP field r
32 = HasTotalFieldP field l || HasTotalFieldP field r
src/Data/Generics/Internal/HList.hs+12−12
@@ -11,16 +11,18 @@
11{-# LANGUAGE TypeOperators #-}
11{-# LANGUAGE TypeOperators #-}
12{-# LANGUAGE UndecidableInstances #-}
12{-# LANGUAGE UndecidableInstances #-}
13
13
14+-----------------------------------------------------------------------------
15+-- |
16+-- Module : Data.Generics.Internal.HList
17+-- Copyright : (C) 2017 Csongor Kiss
18+-- License : BSD3
19+-- Maintainer : Csongor Kiss <kiss.csongor.kiss@gmail.com>
20+-- Stability : experimental
21+-- Portability : non-portable
22+--
23+-----------------------------------------------------------------------------
14module Data.Generics.Internal.HList
24module Data.Generics.Internal.HList
15− ( HList (..)
16−
17− , head'
18− , tail'
19−
20− , append
21− , (++)
25+ ( (++)
22−
23− , Splittable (..)
24
26
25 , ListTuple (..)
27 , ListTuple (..)
26
28
@@ -47,9 +49,6 @@ append (x :> xs) ys = x :> append xs ys
47head' :: HList (a ': as) -> a
49head' :: HList (a ': as) -> a
48head' (x :> _) = x
50head' (x :> _) = x
49
51
50−tail' :: HList (a ': as) -> HList as
51−tail' (_ :> xs) = xs
52−
53--------------------------------------------------------------------------------
52--------------------------------------------------------------------------------
54-- * Split HList
53-- * Split HList
55
54
@@ -142,6 +141,7 @@ instance ListTuple (a, b, c, d, e, f, g, h, j, k, l) '[a, b, c, d, e, f, g, h, j
142 = (a, b, c, d, e, f, g, h, j, k, l)
141 = (a, b, c, d, e, f, g, h, j, k, l)
143
142
144--------------------------------------------------------------------------------
143--------------------------------------------------------------------------------
144+
145class GCollectible (f :: Type -> Type) (as :: [Type]) | f -> as where
145class GCollectible (f :: Type -> Type) (as :: [Type]) | f -> as where
146 gtoCollection :: f x -> HList as
146 gtoCollection :: f x -> HList as
147 gfromCollection :: HList as -> f x
147 gfromCollection :: HList as -> f x
src/Data/Generics/Sum/Constructors.hs+3−3
@@ -28,9 +28,6 @@ module Data.Generics.Sum.Constructors
28
28
29 -- $example
29 -- $example
30 AsConstructor (..)
30 AsConstructor (..)
31−
32− -- *Internals
33− , GAsConstructor (..)
34 ) where
31 ) where
35
32
36import Data.Generics.Internal.Families
33import Data.Generics.Internal.Families
@@ -77,10 +74,13 @@ class AsConstructor (ctor :: Symbol) a s | s ctor -> a where
77 --
74 --
78 -- >>> dog ^? _Ctor @"Dog"
75 -- >>> dog ^? _Ctor @"Dog"
79 -- Just (MkDog {name = "Shep", age = 3})
76 -- Just (MkDog {name = "Shep", age = 3})
77+ --
80 -- >>> dog ^? _Ctor @"Cat"
78 -- >>> dog ^? _Ctor @"Cat"
81 -- Nothing
79 -- Nothing
80+ --
82 -- >>> cat ^? _Ctor @"Cat"
81 -- >>> cat ^? _Ctor @"Cat"
83 -- Just ("Mog", 5)
82 -- Just ("Mog", 5)
83+ --
84 -- >>> _Ctor @"Cat" # ("Garfield", 6) :: Animal
84 -- >>> _Ctor @"Cat" # ("Garfield", 6) :: Animal
85 -- Cat ("Garfield", 6)
85 -- Cat ("Garfield", 6)
86 _Ctor :: Prism' s a
86 _Ctor :: Prism' s a