eadVar :: Serialize c => ST c -> ST c
readVar (ST f)=  ST(\(Stat(c,s,v))->
     let
       s1= B.dropWhile isSpace s
       (var, str2) = B.span isAlphaNum s1
       str3= B.dropWhile isSpace str2
       nvar= numVar $ unpack var

     in  if B.null var then Left (Error "expected variable name" )
         else
          case  trytofindEntireObject nvar c of

           Just  (_,x,_) ->  Right(Stat(c,str3,v),unsafeCoerce x)
           Nothing ->
            let
               (_, rest)= readContext (var `append` "= ") v

            in if B.null rest then Left (Error ( "RedSerialize: readVar: " ++ unpack var ++ "value not found" ))
               else  case f  (Stat(c,rest,v)) of

                 Right (Stat(c',s',v'),x) ->
                   let c''= insert nvar ( undefined, unsafeCoerce x,  "") c'
                   in  Right (Stat(c'', str3,v),x)

                 err -> err)
  where
  trytofindEntireObject x c=
         case Data.RefSerialize.Serialize.lookup   x  c  of
           Nothing -> Nothing
           justx   -> justx


-- |  Write a String in the serialized output with an added whitespace. Deserializable with `symbol`

readVar :: Serialize c => ST c -> ST c
readVar (ST f)=  ST(\(Stat(c,s,v))->
     let
       s1= B.dropWhile isSpace s
       (var, str2) = B.span isAlphaNum s1
       str3= B.dropWhile isSpace str2
       nvar= numVar $ unpack var

     in  if B.null var then Left (Error "expected variable name" )
         else
          case  trytofindEntireObject nvar c of

           Just  (_,x,_) ->  Right(Stat(c,str3,v),unsafeCoerce x)
           Nothing ->
            let
               (_, rest)= readContext (var `append` "= ") v

            in if B.null rest then Left (Error ( "RedSerialize: readVar: " ++ unpack var ++ "value not found" ))
               else  case f  (Stat(c,rest,v)) of

                 Right (Stat(c',s',v'),x) ->
                   let c''= insert nvar ( undefined, unsafeCoerce x,  "") c'
                   in  Right (Stat(c'', str3,v),x)

                 err -> err)
  where
  trytofindEntireObject x c=
         case Data.RefSerialize.Serialize.lookup   x  c  of
           Nothing -> Nothing
           justx   -> justx


-- |  Write a String in the serialized output with an added whitespace. Deserializable with `symbol`
readVar (ST f)=  ST(\(Stat(c,s,v))->
     let
       s1= B.dropWhile isSpace s
       (var, str2) = B.span isAlphaNum s1
       str3= B.dropWhile isSpace str2
       nvar= numVar $ unpack var

     in  if B.null var then Left (Error "expected variable name" )
         else
          case  trytofindEntireObject nvar c of

           Just  (_,x,_) ->  Right(Stat(c,str3,v),unsafeCoerce x)
           Nothing ->
            let
               (_, rest)= readContext (var `append` "= ") v

            in if B.null rest then Left (Error ( "RedSerialize: readVar: " ++ unpack var ++ "value not found" ))
               else  case f  (Stat(c,rest,v)) of

                 Right (Stat(c',s',v'),x) ->
                   let c''= insert nvar ( undefined, unsafeCoerce x,  "") c'
                   in  Right (Stat(c'', str3,v),x)

                 err -> err)
  where
  trytofindEntireObject x c=
         case Data.RefSerialize.Serialize.lookup   x  c  of
           Nothing -> Nothing
           justx   -> justx


-- |  Write a String in the serialized output with an added whitespace. Deserializable with `symbol`