Created
March 19, 2018 15:42
-
-
Save oisdk/c42dc46c655d8ab87c10c235b1991cc3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Free c a = Free { runFree ∷ ∀ b. c b ⇒ (a → b) → b } | |
type (a ∷ k → Constraint) ⊨ (b ∷ k → Constraint) = (∀ x. a x ⇒ b x ∷ Constraint) | |
instance (Monoid ⊨ c) ⇒ Foldable (Free c) where | |
foldMap = flip runFree | |
ala ∷ (∀ x. c x ⇒ c (f x), ∀ x. Coercible x (f x)) ⇒ Free c a → (∀ x. x → f x) → Free c a | |
ala xs to = Free (\k → coerce (runFree xs (to #. k))) | |
reverse ∷ Free Monoid a → Free Monoid a | |
reverse xs = xs `ala` Dual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment