Dear all,
At the moment, a discussion on haskell-cafe is going on
about how to neatly program the fact that an entire program
depends on a number of parameters that are read in once at
the beginning of a program.
The suggestion that many people came up with was using
unsafePerformIO in the begin
Hal Daume III suggested:
| data Configuration = ... -- config data
|
| globalConfig :: IORef Configuration
| globalConfig = unsafePerformIO (newIORef undefined)
:
| getConfig :: Configuration
| getConfig = unsafePerformIO $ readIORef globalConfig
:
| main = do
|...read configuratio
G'day all.
On Thu, Sep 26, 2002 at 12:06:36AM +0100, Liyang Hu wrote:
> The problem I'm having is with the preferences: How do I make it
> available throughout the entire program? (FWIW, most of the work is
> effectively done inside the IO monad.) I could explicitly pass the
> record around ever
Dear Sir or Madam
In the past you have requested information on discounted products. We hope that you
find this of interest. If you are not a smoker, and find this email offensive, we
sincerely apologise! We will be only too happy to take you off our mailing list.
If you are a smoker, howeve
I don't mean to troll, but this isn't what I meant. Suppose we have:
data Configuration = ... -- config data
globalConfig :: IORef Configuration
globalConfig = unsafePerformIO (newIORef undefined)
Now, we define an unsafe function to read the configuration:
getConfig :: Confi
> Evening,
>
> I'm trying to write a utility that reads in some user preferences from
> a pre-determined file, does some work, and exits. Sounds simple enough.
>
> The problem I'm having is with the preferences: How do I make it
> available throughout the entire program? (FWIW, most of the work i
On Wed, 25 Sep 2002 16:06:29 -0700 (PDT)
Hal Daume III <[EMAIL PROTECTED]> wrote:
> I don't feel bad about doing
> this because GHC does this itself for its own configuration :).
I am going to show you that using unsafePerformIO where there really are
side effects leads to unpredictable results
Sorry, I should also mention implicit parameters, if you're willing to use
that extension. I don't like them, though, and my impression from SPJ is
that it's very unclear whether they will get into Haskell 2 or not...
--
Hal Daume III
"Computer science is no more about computers| [EMAIL PR
AFAIK, the global variable (so-called), passing around, and lifting the IO
monad are your only options. I almost always use the global variable
method since I know that in this case the unsafePerformIO is actually
safe, since writing to the variable will always occur before the call to
upIO and t
Evening,
I'm trying to write a utility that reads in some user preferences from
a pre-determined file, does some work, and exits. Sounds simple enough.
The problem I'm having is with the preferences: How do I make it
available throughout the entire program? (FWIW, most of the work is
effectively
charset="US-ASCII";
charset="US-ASCII";
charset="US-ASCII";
charset="US-ASCII"
Reply-To: [EMAIL PROTECTED]
Date: Thu, 26 Sep 2002 00:12:08 +0300
X-Priority: 3
X-Library: Indy 9.00.10
X-Mailer: Foxmail
Kemoterapinin yan etkileri nedeniyle yorgun ve bitkin düsmüs bir yakini
Among other things, please make sure your layout lines up. Also, you
cannot have the definition of getText at the same indentation of
"userText<-getText" otherwise your compiler will think this is part of the
do statement (I believe):
> main=do userText<-getText
> ---
I am new to haskell.
I am trying to do some "excersise" but i can't make anything work :(
This is my code.I replaced spaces with underscores ( _ )
Thanks for any suggestions or correctrions
import IO
import System
import List
import Maybe
import Char
import Numeric
type Name=String
type Room=In
13 matches
Mail list logo