Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lift instance #53

Open
OlivierSohn opened this issue May 7, 2018 · 6 comments
Open

Lift instance #53

OlivierSohn opened this issue May 7, 2018 · 6 comments

Comments

@OlivierSohn
Copy link

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.

@CetinSert
Copy link
Member

CetinSert commented Jul 3, 2018

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?

@OlivierSohn
Copy link
Author

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.

@OlivierSohn
Copy link
Author

OlivierSohn commented Jul 3, 2018

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) |]

@OlivierSohn
Copy link
Author

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.

@CetinSert
Copy link
Member

@OlivierSohn - just got my hackage account back in shape and uploaded a new version of clock!

  1. Is there a way to define a Lift instance without template-haskell?
  2. Why exactly is template-haskell needed?

@Mathnerd314
Copy link
Contributor

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). 5fa98d9

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants