Skip to content

Instantly share code, notes, and snippets.

@khibino
Created May 10, 2019 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khibino/1a7acdda1e43074a5cde58ef7e381776 to your computer and use it in GitHub Desktop.
Save khibino/1a7acdda1e43074a5cde58ef7e381776 to your computer and use it in GitHub Desktop.
with placeholder example
{-# LANGUAGE FlexibleInstances #-}
import Data.DList
import Control.Monad.Trans.Writer (Writer)
import Data.Functor.ProductIsomorphic
data PH a = PH
newtype WithPhT r a =
WithPhT { runWithPhT :: Writer (DList Int) (r a) }
instance ProductIsoFunctor (WithPhT PH) where
_ |$| wx = WithPhT $ runWithPhT wx *> return PH
instance ProductIsoApplicative (WithPhT PH) where
pureP _ = WithPhT $ return PH
wx |*| wy = WithPhT $ runWithPhT wx *> runWithPhT wy *> return PH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment