Created
October 23, 2013 00:12
-
-
Save tmhedberg/7110385 to your computer and use it in GitHub Desktop.
Turn any function of type `a -> a -> a` into a variadic function
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
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} | |
module Data.Function.Variadic where | |
class Variadic a r where variadic :: (a -> a -> a) -> a -> r | |
instance Variadic a a where variadic _ = id | |
instance Variadic a r => Variadic a (a -> r) where | |
variadic f x = variadic f . f x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment