I reply , but I like to make some comments before:
As readers would have noticed from the former email my answers are put here
in a different context.
This might give the reader the false impression that I made some serious
mistakes in the formal
email.
> Fri, 12 May 2000 00:42:52 +0200, Jan Brosius <[EMAIL PROTECTED]>
pisze:
>
> > newSTRef :: a -> ST s (STRef s a)
> > readSTRef :: STRef s a -> ST s a
> > and
> >
> > f:: STRef s a -> STRef s a
> > f v = runST( newSTRef v >= \w -> readSTRef w)
> >
Here you have omitted something of the former email . By doing that the
context of the below has changed.
Readers may think that I committed an error! Is this a HONEST way to reply?
> > Let's start
> >
> > v has type STRef s a
>
> ...for "s" and "a" coming from the instantiation of a polymorphic
> function "f". Yes.
Next one sees that below something is reproduced but out of the context of
the former email.
>
> > newSTRef v has type ST s (STRef s (STRef s a))
> > (THIS is of the form ST s (STRef s T(s))
>
> No. It has the type
> ST s1 (STRef s1 (STRef s a))
That is indeed what I said in my former email where I
stated that newSTRef does NOT deliver something with type St s (STRef s
T(s))v and where you
said the CONYRARY.
> where "s1" is free (thus can be later generalized over) and "s" and
> "a" come from the environment inside "f" (thus are monomorphic).
Really? are there now 2 sorts of variables , variables that are variables
and variables that are not variables?
Interesting?
>
> It would have the type you wrote if "v" was created in this thread.
??
>
> > > > Now forall s1. ( ST s1 T(s)) IMPLIES forall s . ( ST s T(s) )
> > >
> > > It does not. And I have already told why, a few e-mails ago.
Why then doen't you repeat it here? Because this is most interesting for the
reader.
In which email have you told it ? In a private email ? or in the
Haskell-list?
> >
> > IT DOES : that is a well known rule of forall (forall x,y . alpha(x.y)
=>
> > forall x. alpha(x,x) )
>
> I see no "forall s" in the left type.
I shall make it easier:
forall s1. ST s1 T(s) is EQUIVALENT with forall s1,s. ST s1 T(s)
Now forall s1.s ST s1 T(s) IMPLIES ( =>) forall s1. ST s1 T(s1)
Marcin, forall s1 . alpha(s1,s) is EQUIVALENT with alpha(s1,s)
One has alpha(s1,s) IMPLIES alpha(s,s) and the latter is EQUIVALENT to
forall s. alpha (s,s)
>
> > > When you use runST, you don't always know if the type given for "s"
> > > will be instantiated to a type variable or not. Being a type variable
> > > is not a property of a type.
> >
> > I can only say here : ???????????????
>
> runST':: ST s Int -> Int
> runST' x = ...
>
> Inside the body of runST' "x" has the type "ST s Int", with "s"
> taken from the environment.
s is here a type variable , isn't it?
>
> When runST' will be later applied to a value of the type "ST s Int"
> with "s" free, "x" will have the type "ST s Int" with nothing more
> known about "s". (If runST was applied to this value directly, it
> would be OK.)
>
> When runST' will be applied to a value of the type "ST RealWorld Int",
> "x" will have the type "ST RealWorld Int".
I thought that runST does not work on types of the form ST Blurb Int
Has something changed in the documentation?
>
> But you have to compile runST' _now_, and decide whether the first
> argument of ST from the type of "x" is a type variable.
>
> Haskell does not have this problem. It does not ever check if a type
> is a type variable, but if it is a _free_ type variable, i.e. one
> that can be generalized over.
what's the difference between a -free-type variable and a type variable (if
not
bound by a quantifier)?My, my!! Haskell is even more difficult than I
thought.
>
> > > > > runST':: forall s. ST s Int -> Int
> > > > > runST' x = runST x
> > > > >
> > > > > Should it compile with your type of runST?
"my" type of runST is nothing else but the official runST .
So, I expect that if s is instantiated to the type RealWorld you will get a
problem,
since is not defined for s = RealWorld because runST will not work with
with s= RealWorld.
So, you should get (I guess) an error.
>
> > function runST are fullfilled . So ("my") runST will work.
With this I mean MORE "my" runST is nothing but the OFFICIAL runST.
So I see that your runST' is only partially defined
, like e.g. head :: [a] -> [a] where in the definition one does not
consider the case [a] == [] .
>
> Now I write
> len :: Int
> len = runST' (liftM length (readFile "foo") :: ST RealWorld Int)
> which creates a global value of type Int which changes in time. Oops!
Oops! Did the above program work in Hugs ? Or did it come from your
imagination?
VERY FRIENDLY
JAN BROSIUS
>
> --
> __("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
> \__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
> ^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
> QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-
>
>
>