Skip to content

Instantly share code, notes, and snippets.

@diegoeche
Created November 30, 2009 20:48
Show Gist options
  • Save diegoeche/245730 to your computer and use it in GitHub Desktop.
Save diegoeche/245730 to your computer and use it in GitHub Desktop.
> {-# OPTIONS -fglasgow-exts #-}
>
> module VarArg where
> import Data.FiniteMap -- for an example below
>
> class BuildList a r | r-> a where
> build' :: [a] -> a -> r
>
> instance BuildList a [a] where
> build' l x = reverse$ x:l
>
> instance BuildList a r => BuildList a (a->r) where
> build' l x y = build'(x:l) y
>
> --build :: forall r a. (BuildList a r) => a -> r
> build x = build' [] x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment