> > I'm passing that 'record' around as an implicit value. The record as
> > STRefs that I use to collect info, but it also has some pure fields with
> > 'read-only' info. Something like,

<opss let me change 'max' to 'm'> 
> > data E s = E{
> >       refi :: STRef s Int,
> >       refc :: STRef s Char,
> >       m    :: Int  
> >     }
> >
> > In some functions I might need only some pure fields, and none of the
> > STRefs, but since I pass something of type 'E s' around, everything ends
> > up beeing monadic.
>
> there is no reason why that should be the case.  you only need to be
> within the ST monad when you read the references, so if in some function
> you only look at the pure values, it can have a pure type.
> hope this helped
> iavor

That's what I thought, untill I tried it. 
Well, actually you must be right since the pure field defines a pure 
(projection) function... Hmmm, ok, can someone explain this to me,

data E s = E{
      refi :: STRef s Int,
      refc :: STRef s Char,
      m    :: Int
    }

-- this is fine, obviously...
pure   :: E s -> Int
pure e = m e

-- but this is not...
pure2 :: (?e :: E s) => Int
pure2 = m (?e)

Why exactly isn't this allowed? What is the workaround?
Error msg:
------------------------------------------------------------------------
    Ambiguous constraint `?e :: E s'
        At least one of the forall'd type variables mentioned by the 
constraint
        must be reachable from the type after the '=>'
    In the type: forall s. (?e :: E s) => Int
    While checking the type signature for `pure2'
Failed, modules loaded: none.
--------------------------------------------------------------------------

Thanks,
J.A.
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to