File: example.hs

package info (click to toggle)
haskell-generic-data 1.1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: haskell: 2,577; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{-# LANGUAGE
    CPP,
    DeriveGeneric #-}
#if __GLASGOW_HASKELL__ >= 806
{-# LANGUAGE
    DerivingStrategies,
    DerivingVia #-}
#endif

import Data.Semigroup (Semigroup(..))
import Generic.Data (Generic, gmappend, Generically(..))
import Generic.Data.Orphans ()

data Foo a = Bar [a] [a] deriving Generic

instance Semigroup (Foo a) where
  (<>) = gmappend

#if __GLASGOW_HASKELL__ >= 806
data Foo2 a = Bar2 [a] [a]
  deriving Generic
  deriving Semigroup via (Generically (Foo2 a))
#endif

main :: IO ()
main = pure ()