ANN: IOSpec 0.1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ANN: IOSpec 0.1

Wouter Swierstra

* If you're an ICFP referee, you may want to avoid reading any further*


                        Test.IOSpec Version 1.0


I'm pleased to announce the first release of the Test.IOSpec library,  
that provides a pure specification of some functions in the IO monad.  
This may be of interest to anyone who wants to debug, reason about,  
analyse, or test impure code.

Essentially, by importing libraries from IOSpec you can the same code  
you would normally write in the IO monad. Once you're satisfied that  
your functions are reasonably well-behaved, you can remove the  
Test.IOSpec import and replace it with the "real" functions instead.

   Website: www.cs.nott.ac.uk/~wss/repos/IOSpec
   Darcs: darcs get www.cs.nott.ac.uk/~wss/repos/IOSpec
   Tarball: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/IOSpec-0.1.tar.gz
   Haddock: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/doc/html

Several examples are included with the sources.

At the moment, the library consists of the following modules:

   * Test.IOSpec.Teletype: a specification of getChar and putChar.
   * Test.IOSpec.IORef: a specification of most functions on IORefs.
   * Test.IOSpec.Concurrent: specification of forkIO and MVars.

As an added feature, running concurrent code using  
Test.IOSpec.Concurrent will detect deadlocks, instead of looping  
indefinitely.

Future work includes:

   * Improving the interface, making it easier to combine functions  
from different modules.
   * Adding more functionality: STM and weak pointers seem likely  
candidates.

If you have any questions, comments, or feedback, please do get in  
touch.

   Wouter

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________
Haskell mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell
Reply | Threaded
Open this post in threaded view
|

Re: ANN: IOSpec 0.1

Isaac Dupree
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wouter Swierstra wrote:

>
> * If you're an ICFP referee, you may want to avoid reading any further*
>
>
>             Test.IOSpec    Version 1.0
>
>
> I'm pleased to announce the first release of the Test.IOSpec library,
> that provides a pure specification of some functions in the IO monad.
> This may be of interest to anyone who wants to debug, reason about,
> analyse, or test impure code.
>
> Essentially, by importing libraries from IOSpec you can the same code
> you would normally write in the IO monad. Once you're satisfied that
> your functions are reasonably well-behaved, you can remove the
> Test.IOSpec import and replace it with the "real" functions instead.
>
>   Website: www.cs.nott.ac.uk/~wss/repos/IOSpec
>   Darcs: darcs get www.cs.nott.ac.uk/~wss/repos/IOSpec
>   Tarball: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/IOSpec-0.1.tar.gz
>   Haddock: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/doc/html
>
> Several examples are included with the sources.
>
> At the moment, the library consists of the following modules:
>
>   * Test.IOSpec.Teletype: a specification of getChar and putChar.
>   * Test.IOSpec.IORef: a specification of most functions on IORefs.
>   * Test.IOSpec.Concurrent: specification of forkIO and MVars.
>
> As an added feature, running concurrent code using
> Test.IOSpec.Concurrent will detect deadlocks, instead of looping
> indefinitely.
>
> Future work includes:
>
>   * Improving the interface, making it easier to combine functions from
> different modules.
>   * Adding more functionality: STM and weak pointers seem likely
> candidates.
>
> If you have any questions, comments, or feedback, please do get in touch.
>
>   Wouter

How does or might this relate to the typeclass-based Restricted IO monad
http://article.gmane.org/gmane.comp.lang.haskell.general/14526
?  RIO's technique has the advantage that multiple capabilities can be
easily combined in one use of the monad - but this manner of using
typeclasses might interfere with how testable it is? (I think that
should be okay...  Also that this is a really neat project - incremental
progress on taming Haskell IO in practice!)


Isaac

P.S. why
> *If you're an ICFP referee, you may want to avoid reading any further*
?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGLpRmHgcxvIWYTTURAluiAKCc3Bhcp6UXF7j0F1ERfVnzWmhoiQCghb0u
wjPxtoY5PPC6TVavW2WP6YQ=
=BBIK
-----END PGP SIGNATURE-----
_______________________________________________
Haskell mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell
Reply | Threaded
Open this post in threaded view
|

Re: ANN: IOSpec 0.1

Stefan O'Rear
On Tue, Apr 24, 2007 at 07:36:07PM -0400, Isaac Dupree wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Wouter Swierstra wrote:
> >
> > * If you're an ICFP referee, you may want to avoid reading any further*
> >
> >
> >             Test.IOSpec    Version 1.0
> >
> >
> > I'm pleased to announce the first release of the Test.IOSpec library,
> > that provides a pure specification of some functions in the IO monad.
> > This may be of interest to anyone who wants to debug, reason about,
> > analyse, or test impure code.
> >
> > Essentially, by importing libraries from IOSpec you can the same code
> > you would normally write in the IO monad. Once you're satisfied that
> > your functions are reasonably well-behaved, you can remove the
> > Test.IOSpec import and replace it with the "real" functions instead.
> >
> >   Website: www.cs.nott.ac.uk/~wss/repos/IOSpec
> >   Darcs: darcs get www.cs.nott.ac.uk/~wss/repos/IOSpec
> >   Tarball: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/IOSpec-0.1.tar.gz
> >   Haddock: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/doc/html
> >
> > Several examples are included with the sources.
> >
> > At the moment, the library consists of the following modules:
> >
> >   * Test.IOSpec.Teletype: a specification of getChar and putChar.
> >   * Test.IOSpec.IORef: a specification of most functions on IORefs.
> >   * Test.IOSpec.Concurrent: specification of forkIO and MVars.
> >
> > As an added feature, running concurrent code using
> > Test.IOSpec.Concurrent will detect deadlocks, instead of looping
> > indefinitely.
> >
> > Future work includes:
> >
> >   * Improving the interface, making it easier to combine functions from
> > different modules.
> >   * Adding more functionality: STM and weak pointers seem likely
> > candidates.
> >
> > If you have any questions, comments, or feedback, please do get in touch.
> >
> >   Wouter
>
> How does or might this relate to the typeclass-based Restricted IO monad
> http://article.gmane.org/gmane.comp.lang.haskell.general/14526
> ?  RIO's technique has the advantage that multiple capabilities can be
> easily combined in one use of the monad - but this manner of using
> typeclasses might interfere with how testable it is? (I think that
> should be okay...  Also that this is a really neat project - incremental
> progress on taming Haskell IO in practice!)

As I see it (NB: I wrote RIO) RIO and IOSpec solve very different
problems.  RIO is all about embedding capabilities in the type system,
and allowing update-in-place with more flexibility than ST.  In
contrast IOSpec seems to be the exact opposite - it provides an
IO-like interface to *im*mutable state.

Also note that RIO contains an slow, bug-ridden, ad-hoc, informally
specified implementation of half of HList.

Looks very neat, Wouter - I look forward to having an excuse to use it!

Aside:

in the Teletype module, it would probably be better to reflect
IOTeletype operations as:

data Action a = Finish a | Put Char (Action a) | Get (Char -> Action a)

That way, there is no need to use (unobservable) laziness.

Stefan
     
_______________________________________________
Haskell mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell
Reply | Threaded
Open this post in threaded view
|

Re: ANN: IOSpec 0.1

Stefan O'Rear
In reply to this post by Wouter Swierstra
On Mon, Apr 23, 2007 at 04:16:56PM +0100, Wouter Swierstra wrote:

>
> * If you're an ICFP referee, you may want to avoid reading any further*
>
>
> Test.IOSpec Version 1.0
>
>
> I'm pleased to announce the first release of the Test.IOSpec library,  
> that provides a pure specification of some functions in the IO monad.  
> This may be of interest to anyone who wants to debug, reason about,  
> analyse, or test impure code.
>
> Essentially, by importing libraries from IOSpec you can the same code  
> you would normally write in the IO monad. Once you're satisfied that  
> your functions are reasonably well-behaved, you can remove the  
> Test.IOSpec import and replace it with the "real" functions instead.
>
>   Website: www.cs.nott.ac.uk/~wss/repos/IOSpec
>   Darcs: darcs get www.cs.nott.ac.uk/~wss/repos/IOSpec
>   Tarball: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/IOSpec-0.1.tar.gz
>   Haddock: www.cs.nott.ac.uk/~wss/repos/IOSpec/dist/doc/html
>
> Several examples are included with the sources.
>
> At the moment, the library consists of the following modules:
>
>   * Test.IOSpec.Teletype: a specification of getChar and putChar.
>   * Test.IOSpec.IORef: a specification of most functions on IORefs.
>   * Test.IOSpec.Concurrent: specification of forkIO and MVars.
>
> As an added feature, running concurrent code using  
> Test.IOSpec.Concurrent will detect deadlocks, instead of looping  
> indefinitely.
>
> Future work includes:
>
>   * Improving the interface, making it easier to combine functions  
> from different modules.
>   * Adding more functionality: STM and weak pointers seem likely  
> candidates.
>
> If you have any questions, comments, or feedback, please do get in  
> touch.

I suggest you check out:

http://members.cox.net/stefanor/GenDirListings.hs

example output:

http://members.cox.net/stefanor/vty

Stefan
_______________________________________________
Haskell mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell
Reply | Threaded
Open this post in threaded view
|

Re: ANN: IOSpec 0.1

Twan van Laarhoven
In reply to this post by Wouter Swierstra
Wouter Swierstra wrote:
>             Test.IOSpec    Version 1.0
Shouldn't that be 0.1?

>   * Test.IOSpec.Teletype: a specification of getChar and putChar.

You use Dynamic for the data type in IORefs, this has the unfortunate
consequence of needing Typeable constraints. You could try to use
unsafeCoerce instead,
 > type Data = ()
 > unsafeToData :: a -> Data
 > unsafeToData = unsafeCoerce
 > unsafeFromData :: Data -> a
 > unsafeFromData = unsafeCoerce

I think this should be just as safe as Dynamic, since internally Dynamic
uses unsafeCoerce as well. Just steal the details from there.

Twan
_______________________________________________
Haskell mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell
Reply | Threaded
Open this post in threaded view
|

Re: ANN: IOSpec 0.1

Stefan O'Rear
On Wed, Apr 25, 2007 at 03:22:33AM +0200, Twan van Laarhoven wrote:

> Wouter Swierstra wrote:
> >            Test.IOSpec    Version 1.0
> Shouldn't that be 0.1?
>
> >  * Test.IOSpec.Teletype: a specification of getChar and putChar.
>
> You use Dynamic for the data type in IORefs, this has the unfortunate
> consequence of needing Typeable constraints. You could try to use
> unsafeCoerce instead,
> > type Data = ()
> > unsafeToData :: a -> Data
> > unsafeToData = unsafeCoerce
> > unsafeFromData :: Data -> a
> > unsafeFromData = unsafeCoerce
>
> I think this should be just as safe as Dynamic, since internally Dynamic
> uses unsafeCoerce as well. Just steal the details from there.

Be sure to actually check the details - Twan's code is documented as
not working.  (GHC does naughty things when it thinks it knows the
type, and you need to use a couple of nonportable hacks to make it
work)

Stefan
_______________________________________________
Haskell mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell