[Haskell] Re: getArgs, maxBound, float division: pure functions?

Ashley Yakeley ashley at semantic.org
Mon Oct 24 05:15:59 EDT 2005


In article <20051011060428.B7BC8ACB2 at Adric.metnet.navy.mil>,
 oleg at pobox.com wrote:

> To recap, there were two arguments for getArgs to remain with the 
> IO [String] type:

As was argued earlier, it seems the correct thing would be to retype 
"main":

  main :: [String] -> IO ()

or

  main :: (?args :: [String]) => IO ()

or

  type ReturnCode = Int
  main :: [String] -> IO ReturnCode

I sometimes dream of an approach where all system services are provided 
by implicit parameters supplied to "main":

  main :: (?stdin :: Handle,
    ?stdout :: Handle,
    ?stderr :: Handle,
    ?filesystem :: FileSystem,
    ?internets :: [InternetConnection],
    ?gettime :: IO UTCTime,
    ...
    ) => [String] -> IO ReturnCode

Of course, this would make a bit more sense if there were a mechanism 
for applying type contexts to modules, so that they applied to all 
declared type signatures.

-- 
Ashley Yakeley, Seattle WA



More information about the Haskell mailing list