
Hi. I'm trying to derive some instances using DrIFT, but it will only work for me when I'm deriving for types in the current file or in the prelude. For example, this works:
module Test where
{-! for Maybe derive : Haskell2Xml !-}
this works:
module Test where
data Foo = Foo
{-! for Foo derive : Haskell2Xml !-}
but this doesn't:
module Test where
import Data.Word
{-! for Word32 derive : Haskell2Xml !-}
It fails to load the first import, giving an error as follows: {- Generated by DrIFT (Automatic class derivations for Haskell) -} {-# LINE 1 "Test.hs" #-} DrIFT: can't find module Data.Word Any ideas as to why that is? Thanks Daniel

On Mon, Oct 30, 2006 at 01:24:58PM +1300, Daniel McAllansmith wrote:
I'm trying to derive some instances using DrIFT, but it will only work for me when I'm deriving for types in the current file or in the prelude.
Since DrIFT can only understand haskell source code, it can't derive instances for anything you don't have the original source to. such as things in the pre-compiled libraries that come with ghc. you will likely have to write out those instances by hand. Another possibility is that you could replicate just the data declarations by hand, and use DrIFT -r to just spit out the derivations and put those in a file on their own. a long time ago DrIFT used to be able to read ghc 'hi' files, but that has not worked in a while, it is possible not all the documentation has been updated to reflect that. John -- John Meacham - ⑆repetae.net⑆john⑈

On 29.10 19:56, John Meacham wrote:
Since DrIFT can only understand haskell source code, it can't derive instances for anything you don't have the original source to. such as things in the pre-compiled libraries that come with ghc. you will likely have to write out those instances by hand.
Another possibility is that you could replicate just the data declarations by hand, and use DrIFT -r to just spit out the derivations and put those in a file on their own.
How about using Template Haskell for getting the definition and then giving that to DrIFT? - Einar Karttunen

On Monday 30 October 2006 22:18, Einar Karttunen wrote:
On 29.10 19:56, John Meacham wrote:
Since DrIFT can only understand haskell source code, it can't derive instances for anything you don't have the original source to.
Ahhh, ok.
such as things in the pre-compiled libraries that come with ghc. you will likely have to write out those instances by hand.
Hmmm, seems strange that it can successfully derive for the Data.Maybe type but not the Data.Word32 type. I didn't think it would have access to any original source from my ghc install, there only seems to be hi files.
Another possibility is that you could replicate just the data declarations by hand, and use DrIFT -r to just spit out the derivations and put those in a file on their own.
How about using Template Haskell for getting the definition and then giving that to DrIFT?
Thanks for the suggestions. Daniel

On Tue, Oct 31, 2006 at 07:46:05AM +1300, Daniel McAllansmith wrote:
Hmmm, seems strange that it can successfully derive for the Data.Maybe type but not the Data.Word32 type. I didn't think it would have access to any original source from my ghc install, there only seems to be hi files.
It has a few data definitions built into it. Bool,Maybe,Either, and Ordering. see src/PreludData.hs for how that is done. John -- John Meacham - ⑆repetae.net⑆john⑈
participants (3)
-
Daniel McAllansmith
-
Einar Karttunen
-
John Meacham