On Sun, 2011-01-30 at 05:20 -0500, Ryan Newton wrote:
>
> I am trying to link a ".a" file built by a separate makefile into my
> library. GHC has no problem with it, but I need to convince cabal to
> do it for the package to be hackage-friendly. There's a thread about
> this back in 2007:
>
> http://www.haskell.org/pipermail/cabal-devel/2007-April/000507.html
>
> Is there a method for this now, or is the state of affairs the same as
> before?
Having a Haskell package link against an external C library is
straightforward, you just list it in the extra-libraries field. The
external library must already be installed on the system however.
Bundling a copy of the external library with a cabal package is not
quite so easy. You will have to write code in the Setup.hs to call the
separate makefile during the build (and perhaps extra steps at configure
time too).
Your best bet is probably to use the "simple" build system's hooks API.
You can list the library in the extra-libraries field in the .cabal file
but you will also need to modify the check for external libraries that
are done in the postConf hook (since the separate .a library will not be
available at configure time): modify the package description that gets
passed to the postConf hook to exclude the library.
Duncan
tldr: Can I make arbitrary instances of one class instantiate another without
using wrappers?
I'm new to Haskell, and am trying to implement some simple typeclasses for
doing algebra. For example I have type class (simplified for the sake of
argument)
class AbGroup a where
add :: a -> a -> a
I would like any type instantiating Num to also be an abelian group:
instance (Num a) => AbGroup a where
add i j = i+j,
but this doesn't compile because a is a variable, not a type constructor(or
something). The problem is fixed, in a sense, If I introduce a wrapper
class
data Wrapper a = Wrap a
instance (Num a) => AbGroup (Wrapper a) where
add (Wrap i) (Wrap j) = Wrap(i+j)
However, this is clumsy. Is there something else I can do? Thanks!
--
View this message in context: http://haskell.1045720.n5.nabble.com/Inheritance-and-Wrappers-tp3365126p336…
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.