Lift instance
Hello,
I would need TimeSpec to have a Lift instance. Would you consider taking a PR on that subject considering it adds a dependency on template-haskell?
Note that I can live without it for the moment, by manually implementing the Lift instance on the wrapper type.
Is template-haskell available everywhere? How widely is it installed? How does it interact with cross-compilation?
Also why not add your manual Lift instance in a PR without referencing template-haskell?
Also why not add your manual Lift instance in a PR without referencing template-haskell?
The Lift class is in Language.Haskell.TH.Syntax, this is why we need to reference template-haskell.
Btw, the Liftinstance I implemented for my type is:
newtype Time a b = Time TimeSpec
deriving(Generic, Eq, Ord)
instance Lift (Time a b) where
lift (Time (TimeSpec s ns)) = [| Time (TimeSpec $(lift s) $(lift ns)) |]
So the Liftinstance for TimeSpec should be:
instance Lift TimeSpec where
lift (TimeSpec s ns) = [| TimeSpec $(lift s) $(lift ns) |]
Is template-haskell available everywhere? How widely is it installed? How does it interact with cross-compilation?
It's available on hackage, do you mean "which platforms are supported?"
I have no idea about cross compilation interactions as I don't cross-compile.
@OlivierSohn - just got my hackage account back in shape and uploaded a new version of clock!
- Is there a way to define a
Liftinstance withouttemplate-haskell? - Why exactly is
template-haskellneeded?
The Lift class is defined in the package template-haskell, hence there is no way to define an instance without depending on the package. But the package is a core library included with GHC, so depending on it doesn't add any footprint. There is the DeriveLift extension so it is just importing the class and writing ... deriving (..., Lift). https://github.com/corsis/clock/commit/5fa98d9f9461d48d75e55433cbef7aacbf6fe11c
But you can also define an instance easily using StandaloneDeriving, so I don't know if it's worth it. Most users will not be using this library with Template Haskell.