3 ms·
License Monads
- quchen 13y agoThis requies only Applicative, not Monad. Furthermore, this does not allow mixing licences without explicit conversion functions (liftGPL). Conceptually a nicer interface would be having a datatype unifying licences such as data Licence a = GPL a | BSD a with some Monad instance that encodes that adding GPL code to a BSD project makes everything GPL, instance Functor Licence where fmap f (BSD x) = BSD (f x) fmap f (GPL x) = GPL (f x) instance Applicative Licence where pure = BSD (<*>) = ap instance Monad Licence where join (GPL (BSD x)) = GPL x join (GPL x ) = x join (BSD x ) = x but I'm not sure the Monad laws hold here.