blob: 281e8def9fd09025a12e13281226cc3555b71a8e (
plain)
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
27
28
29
30
31
32
33
34
35
|
{- authorship made explicit in the code
-
- Copyright 2023 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE FlexibleInstances, RankNTypes #-}
{-# OPTIONS_GHC -fno-warn-tabs #-}
module Author where
data Author = JoeyHess
-- This allows writing eg:
--
-- copyright = author JoeyHess 1999 :: Copyright
type Copyright = forall t. Authored t => t
class Authored t where
author:: Author -> Int -> t
instance Authored Bool where
author _ year = year >= 2010
{-# INLINE author #-}
instance Authored (a -> a) where
author by year f
| author by year = f
| otherwise = author by (pred year) f
{-# INLINE author #-}
instance Monad m => Authored (a -> m a) where
author by year = pure . author by year
{-# INLINE author #-}
|