3

I'm trying to use the SPECIALIZE pragma to a type I get through hsc2hs's #type.

I tried something like this:

{-# SPECIALIZE someFn :: #{type DWORD} -> #{type DWORD} -> Bool #-}
someFn :: Eq a => a -> a -> Bool

That attempt fails with a parse error on input '#' (on the first #{type DWORD}).

I've put an answer that I found to work but I'm really hoping for something cleaner -- or more precisely: something that doesn't impact the entire module's code.

MasterMastic
  • 20,711
  • 12
  • 68
  • 90

1 Answers1

4

It's possible to delegate the #type using a type declaration:

type SDWORD = #{type DWORD}
{-# SPECIALIZE someFn :: SDWORD -> SDWORD -> Bool #-}
someFn :: Eq a => a -> a -> Bool
MasterMastic
  • 20,711
  • 12
  • 68
  • 90