never executed always true always false
1 module Data.Coapplicative (Coapplicative(..)) where
2
3 import Data.Functor.Compose
4 import Data.Functor.Identity
5
6
7 class Functor f => Coapplicative f where
8 extract :: f a -> a
9
10 instance Coapplicative ((,) x) where
11 extract (_, a) = a
12 {-# INLINE extract #-}
13
14 instance Coapplicative Identity where
15 extract = runIdentity
16 {-# INLINE extract #-}
17
18 instance (Coapplicative a, Coapplicative b) => Coapplicative (Compose a b) where
19 extract = extract . extract . getCompose
20 {-# INLINE extract #-}