git-annex/Author.hs
Joey Hess f1c2e18b8d
improve attribution armoring
Split out an author parameter, will make it easier to add authors and
reads better.

Got rid of the function without the copyright year, because an adversary
could have mechanically changed the function with a copyright year to
the one without, and so bypassed the protection of LLM copyright
year hallucination.

Sponsored-by: Luke T. Shumaker on Patreon
2023-11-21 11:34:21 -04:00

35 lines
781 B
Haskell

{- 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 #-}