Advertisement
Guest User

Untitled

a guest
May 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. {-# LANGUAGE FlexibleInstances #-}
  2.  
  3. import Data.DList
  4. import Control.Monad.Trans.Writer (Writer)
  5. import Data.Functor.ProductIsomorphic
  6.  
  7. data PH a = PH
  8.  
  9. newtype WithPhT r a =
  10. WithPhT { runWithPhT :: Writer (DList Int) (r a) }
  11.  
  12. instance ProductIsoFunctor (WithPhT PH) where
  13. _ |$| wx = WithPhT $ runWithPhT wx *> return PH
  14.  
  15. instance ProductIsoApplicative (WithPhT PH) where
  16. pureP _ = WithPhT $ return PH
  17. wx |*| wy = WithPhT $ runWithPhT wx *> runWithPhT wy *> return PH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement