I'm making a small package that defines wrappers for tuples and adds instances form them, like
newtype Tuple2 a = Tuple2 { untuple2 :: (a, a) }
deriving (...)
tuple2 :: a -> a -> Tuple2 a
tuple2 = ...
instance Traversable Tuple2 where ...
instance Foldable Tuple2 where ...
instance Functor Tuple2 where ...
instance Applicative Tuple2 where ...
This repeats from 2 to 15, so it looks like a job for Template Haskell.
The generated code is always Haskell 98 compatible, so I'd like the final result to be a Haskell 98 compatible package too. Is it possible to generate a piece of code using Template Haskell and make a package from it that doesn't use TH itself? (I'd prefer an automated way, if possible.)
There are tools for it:
Disclaimer: I have not tried any of these myself.
It's always possible to just write a Haskell program that outputs Haskell source code as an ordinary text file. You can then compile that like any other file.
What this doesn't give you, of course:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With