Skip to content

Instantly share code, notes, and snippets.

@tmhedberg
Created October 23, 2013 00:12
Show Gist options
  • Save tmhedberg/7110385 to your computer and use it in GitHub Desktop.
Save tmhedberg/7110385 to your computer and use it in GitHub Desktop.
Turn any function of type `a -> a -> a` into a variadic function
{-# 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