[Haskell-cafe] Main function variables made global.

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Thu Mar 27 11:08:55 UTC 2014


On Thu, Mar 27, 2014 at 10:58:45AM +0000, Chapman, Anthony Sergio wrote:
> 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.

It's not quite clear to me what you're asking, but won't something like this
do?

    do var <- readVar
       let func w = w * var
       let result = psoFunction func

Tom


More information about the Haskell-Cafe mailing list