<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/12/3ae47766c120e8d93ed0b4d9330f4667"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-09T07:56:15"
  subject="[Caml-list] stream conversion"
  prev="2003/12/55566716cad8a85c006e4f6eae19bde6"
  next="2003/12/2605809616be12bd76ecbc561b85fb14"
  next-in-thread="2003/12/8625cd8b15d41a5025c1435d3710629d"
  prev-thread="2003/12/138d25e04135c86384c9d95218fd7b00"
  next-thread="2003/12/336da68464ef2651ac3a251d0d53f270"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] stream conversion">
<msg 
  url="2003/12/3ae47766c120e8d93ed0b4d9330f4667"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-09T07:56:15"
  subject="[Caml-list] stream conversion">
<msg 
  url="2003/12/8625cd8b15d41a5025c1435d3710629d"
  from="Remi Vanicat &lt;remi.vanicat@l...&gt;"
  author="Remi Vanicat"
  date="2003-12-09T12:07:57"
  subject="Re: [Caml-list] stream conversion">
<msg 
  url="2003/12/bc9dc2b12a47d4bcfa85daeb30c1aa27"
  from="Jean-Baptiste Rouquier &lt;jean-baptiste.rouquier@e...&gt;"
  author="Jean-Baptiste Rouquier"
  date="2003-12-09T16:58:50"
  subject="Re: [Caml-list] stream conversion">
<msg 
  url="2003/12/bac10dac5f02b6339a9ca9189c75cddc"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-12-09T17:25:29"
  subject="Re: [Caml-list] stream conversion">
<msg 
  url="2003/12/95d033f811e1ab445412e643be3da233"
  from="Jean-Baptiste Rouquier &lt;jean-baptiste.rouquier@e...&gt;"
  author="Jean-Baptiste Rouquier"
  date="2003-12-09T17:40:23"
  subject="Re: [Caml-list] stream conversion">
</msg>
<msg 
  url="2003/12/5c54ecb9bfb3b517c0719bf7c74d646a"
  from="Tim Freeman &lt;tim@f...&gt;"
  author="Tim Freeman"
  date="2003-12-09T19:43:51"
  subject="Re: [Caml-list] stream conversion">
<msg 
  url="2003/12/7705bdf1a3ecb740b46d00b434db07f4"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-12-16T22:41:15"
  subject="Re: [Caml-list] stream conversion">
</msg>
</msg>
</msg>
<msg 
  url="2003/12/9947980da386f0a0a076c97377241cae"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-09T19:13:29"
  subject="Re: [Caml-list] stream conversion">
</msg>
</msg>
<msg 
  url="2003/12/6ca04e3679ec1004184b76bd53774151"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-09T19:15:21"
  subject="Re: [Caml-list] stream conversion">
</msg>
</msg>
<msg 
  url="2003/12/9ee9052e21abd29b23b1757d11f1890b"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-12-10T01:09:52"
  subject="Re: [Caml-list] stream conversion">
</msg>
</msg>
</thread>

<contents>

	I have a need to convert a ``string stream'' to a ``char stream.''  
It's a little unclear to me how I'd accomplish this.  This is the best 
I've been able to come up with so far, but I have to imagine there's a 
prettier solution:

let stream_convert source =
     let chunk = ref (Stream.of_string (Stream.next source)) in
     Stream.from (fun x -&gt;
         try
             Stream.empty !chunk;
             try
                 Stream.empty source;
                 None
             with Stream.Failure -&gt;
                 chunk := (Stream.of_string (Stream.next source));
                 Some (Stream.next !chunk)
         with Stream.Failure -&gt;
             Some (Stream.next !chunk)
     )
;;

	Any suggestions?

--
SPY                      My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings &lt;dustin@spy.net&gt;
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

