diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2019-06-08 20:48:07 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2019-06-09 14:35:50 +0200 |
commit | 4c44e323e8ac0e28e87e93ab53cbf7eb21ac9c25 (patch) | |
tree | b0991218e9cac8f76224df017856045c71d779e4 /compiler/utils/ListT.hs | |
parent | 8754002973dcde8709458044e541ddc8f4fcf6bb (diff) | |
download | haskell-wip/derive-functor.tar.gz |
Use DeriveFunctor throughout the codebase (#15654)wip/derive-functor
Diffstat (limited to 'compiler/utils/ListT.hs')
-rw-r--r-- | compiler/utils/ListT.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/utils/ListT.hs b/compiler/utils/ListT.hs index 105e27b3d4..66e52ed9f4 100644 --- a/compiler/utils/ListT.hs +++ b/compiler/utils/ListT.hs @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE FlexibleInstances #-} @@ -42,6 +43,7 @@ import Control.Monad.Fail as MonadFail -- layered over another monad 'm' newtype ListT m a = ListT { unListT :: forall r. (a -> m r -> m r) -> m r -> m r } + deriving (Functor) select :: Monad m => [a] -> ListT m a select xs = foldr (<|>) mzero (map pure xs) @@ -55,9 +57,6 @@ fold = runListT runListT :: ListT m a -> (a -> m r -> m r) -> m r -> m r runListT = unListT -instance Functor (ListT f) where - fmap f lt = ListT $ \sk fk -> unListT lt (sk . f) fk - instance Applicative (ListT f) where pure a = ListT $ \sk fk -> sk a fk f <*> a = ListT $ \sk fk -> unListT f (\g fk' -> unListT a (sk . g) fk') fk |