Re: Static library to redefine entrypoint

2009-04-25 Thread Duncan Coutts
On Fri, 2009-04-24 at 12:56 +0200, Philip K.F. Hölzenspies wrote:
 Dear GHCers,
 
 I am trying to write a wrapper library for lab work to give to students.
 My problem is, that the libraries I use require initialization that I
 really want to hide from our students. The wrapper I'm writing is
 compiled to a static library and installed with cabal, so students can
 just ghc --make or ghci their sources. Here comes the problem: I
 want to define main and let students just define labMain as an entry
 point to their program.
 
 How can I have my library use labMain without a definition? Keep in
 mind that I want to give them a cabalized library that they can just
 link to, so I can't give them a template file that they fill and compile
 together with my code. Is it at all possible to have external
 functions and letting the linker sort stuff out?

When I've set practicals like this I've just provided them with a 3 line
Main module that imports functions exported by the module(s) that the
students write. Eg I have them fill in Draw.lhs but tell them to compile
the thing using ghc --make Main.hs. I never found that this confused any
of them (indeed some were interested in looking at the code).

Duncan

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Static library to redefine entrypoint

2009-04-24 Thread Krzysztof Skrzętnicki
Why not just tell them to import your library and do something like
 main = withSomeInit labMain
where withSomeInit is the function you provide? This approach is present
in some other libs that require initialization.

Best regards

Christopher Skrzętnicki

On Fri, Apr 24, 2009 at 12:56, Philip K.F. p.k.f.holzensp...@utwente.nlwrote:

 Dear GHCers,

 I am trying to write a wrapper library for lab work to give to students.
 My problem is, that the libraries I use require initialization that I
 really want to hide from our students. The wrapper I'm writing is
 compiled to a static library and installed with cabal, so students can
 just ghc --make or ghci their sources. Here comes the problem: I
 want to define main and let students just define labMain as an entry
 point to their program.

 How can I have my library use labMain without a definition? Keep in
 mind that I want to give them a cabalized library that they can just
 link to, so I can't give them a template file that they fill and compile
 together with my code. Is it at all possible to have external
 functions and letting the linker sort stuff out?

 Regards,
 Philip

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Static library to redefine entrypoint

2009-04-24 Thread Philip K.F.
On Fri, 2009-04-24 at 13:06 +0200, Krzysztof Skrzętnicki wrote:
 Why not just tell them to import your library and do something like 
  main = withSomeInit labMain
 where withSomeInit is the function you provide? This approach is
 present in some other libs that require initialization.

Dear Christopher,

I know there are alternatives and I know some people use them. A
particular problem I have now, though, is SDL. On OS X, the SDL library
defines an alternative entry-point to the application, called SDL_main,
where the libSDL.a provides a main (insert long story about Cocoa
frameworks and Objective-C linking here). I don't particularly like this
method, but it's the world I have to work with. Also, many alternatives
to SDL don't play nice with GHCi, which is particularly useful for lab
teaching. If I can somehow introduce my own new entry point, I could
also wrap GHCi in something else quite easily (I know I could wrap GHCi
as it is, but it would be even nicer if I could just link to the
binary).

I figured this level of detail would distract form the question, though
and I would run the risk that people would try to solve my SDL linking
woes, which is not the point of the question.

Regards,
Philip

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users