[Haskell-cafe] Main function variables made global.

Chapman, Anthony Sergio a.s.chapman.10 at aberdeen.ac.uk
Thu Mar 27 10:58:45 UTC 2014


My problem is as follows (not actual code), I declare a function outside of the main function

func w = w * var

I get the value of  'var' from a text file in the main function (as the user types the name of the file into terminal)

I need a way for 'func' to see what 'var' is without  having to change it's type (ie make it into a function which take a 'w' and a 'var'.

The reason I can't change the type is that I then pass the function to a PSO module which has strict declarations of a function and I would rather not change the PSO module.

I also can't put 'func' into main because 'w' isn't specified. The PSO will find the best w so I don't get it a value.

I have thought about making a dummy function which has an input of 'w' and 'var' and an output of a function of just 'w'. Something like: func w = func' w var.

I got the function for PSO to optimise and the function to get the data I want from a text file working great, they both do what they're supposed to do. I just need the function of PSO to see the data I get from the file.

If you need any more information (sorry if I've been too vague) please let me know.

Thank you for your time.?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140327/f213a725/attachment.html>

More information about the Haskell-Cafe mailing list