Skip to content

Instantly share code, notes, and snippets.

@dalaing
Last active March 16, 2018 00:39
Show Gist options
  • Save dalaing/39b92cecd48ddb41ec7306080d981234 to your computer and use it in GitHub Desktop.
Save dalaing/39b92cecd48ddb41ec7306080d981234 to your computer and use it in GitHub Desktop.
Tagged final backpack shennanigans
-- final-bp-base-eval
module Base where
import Data.Functor.Identity
lit :: a -> Identity a
lit = Identity
add :: Num a => Identity a -> Identity a -> Identity a
add x y = (+) <$> x <*> y
-- final-bp-base-sig
signature Base where
import Repr
lit :: a -> Repr a
add :: Num a => Repr a -> Repr a -> Repr a
-- final-bp-mul-eval
module Mul where
import Data.Functor.Identity
mul :: Num a => Identity a -> Identity a -> Identity a
mul x y = (*) <$> x <*> y
-- final-bp-mul-sig
signature Mul where
import Repr
mul :: Num a => Repr a -> Repr a -> Repr a
-- final-bp-eval
module Repr where
import Data.Functor.Identity
type Repr = Identity
-- final-bp-repr-sig
signature Repr where
data Repr a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment