# Unamb

### From HaskellWiki

(Difference between revisions)

(→Abstract: fixed the repo pointer fix) |
|||

(10 intermediate revisions by one user not shown) | |||

Line 1: | Line 1: | ||

[[Category:Packages]] |
[[Category:Packages]] |
||

+ | [[Category:Concurrency]] |
||

== Abstract == |
== Abstract == |
||

− | '''unamb''' is a package containing the ''unambiguous choice'' operator <hask>unamb</hask>, which wraps thread racing up in a purely functional, semantically simple wrapper. Given any two arguments <hask>u</hask> and <hask>v</hask> that agree unless bottom, the value of <hask>unamb u v</hask> is the more terminating of <hask>u</hask> and <hask>v</hask>. Operationally, the value of <hask>unamb u v</hask> becomes available when the earlier of <hask>u</hask> and <hask>v</hask> does. The agreement precondition ensures unamb's referential transparency. For more info about <hask>unamb</hask> and its use, see the paper ''[http://conal.net/papers/simply-reactive/ Simply Efficient Functional Reactivity]'', sections 10 and 11. |
+ | '''unamb''' is a package containing the ''unambiguous choice'' operator <hask>unamb</hask>, which wraps thread racing up in a purely functional, semantically simple wrapper. |

+ | Given any two arguments <hask>u</hask> and <hask>v</hask> that agree unless bottom, the value of <hask>unamb u v</hask> is the more terminating of <hask>u</hask> and <hask>v</hask>. |
||

+ | Operationally, the value of <hask>unamb u v</hask> becomes available when the earlier of <hask>u</hask> and <hask>v</hask> does. |
||

+ | The agreement precondition ensures unamb's referential transparency. |
||

+ | For more info about <hask>unamb</hask> and its use, see the paper ''[http://conal.net/papers/push-pull-frp/ Push-pull functional reactive programming]'', sections 10 and 11. |
||

<hask>unamb</hask> was originally a part of [[Reactive]]. I moved it to its own package in order to encourage experimentation. |
<hask>unamb</hask> was originally a part of [[Reactive]]. I moved it to its own package in order to encourage experimentation. |
||

Besides this wiki page, here are more ways to find out about unamb: |
Besides this wiki page, here are more ways to find out about unamb: |
||

− | * Read [http://code.haskell.org/unamb/doc/html/ the library documentation]. |
+ | * Visit the [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unamb Hackage page] for library documentation and to download & install. |

− | * Get the code repository: '''<tt>darcs get http://code.haskell.org/unamb</tt>'''. |
+ | * Read [http://conal.net/blog/tag/unamb/ related blog posts]. |

− | * Install from [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unamb Hackage]. |
+ | * Or install with <tt>cabal install unamb</tt>. |

− | * See the [[unamb/Versions| version history]]. |
+ | * Get the [https://github.com/conal/unamb code repository]. |

− | Please leave comments at the [[Talk:unamb|Talk page]]. |
+ | <!-- * See the [[unamb/Versions| version history]]. --> |

+ | |||

+ | <!-- Please leave comments at the [[Talk:unamb|Talk page]]. --> |
||

+ | See also the [[lub]] package, which extends unamb's usefulness with non-flat types. |
||

+ | |||

+ | == Issues == |
||

+ | |||

+ | Although semantically very simple, unamb has been quite tricky to implement correctly and efficiently. |
||

+ | |||

+ | As of version 0.1.1, unamb requires ghc 6.10 or better. |
||

+ | |||

+ | As of version 0.1.6, unamb correctly handles recursive termination of sub-efforts and automatic restarting, but only with the GHC RTS fixes that first appeared (stably, by my testing) in GHC HEAD version 6.11.20090115. |
||

+ | The problems and solution can be found in a few places: |
||

+ | * Email thread: ''[http://n2.nabble.com/problem-with-unamb----doesn%27t-kill-enough-threads-tt1674917.html Problem with unamb -- doesn't kill enough threads]'' |
||

+ | * Blog post: ''[http://conal.net/blog/posts/smarter-termination-for-thread-racing/ Smarter termination for thread racing]'' |
||

+ | * Email thread: ''[http://n2.nabble.com/Re%3A-black-hole-detection-and-concurrency-td2016290.htm Black hole detection and concurrency]'' |
||

+ | |||

+ | unamb seems to be working well in version 0.2.2, under GHC 6.10.3. |

## Latest revision as of 21:36, 4 February 2014

## [edit] 1 Abstract

**unamb**is a package containing the

*unambiguous choice*operator

unamb

u

v

unamb u v

u

v

unamb u v

u

v

The agreement precondition ensures unamb's referential transparency.

For more info aboutunamb

*Push-pull functional reactive programming*, sections 10 and 11.

unamb

Besides this wiki page, here are more ways to find out about unamb:

- Visit the Hackage page for library documentation and to download & install.
- Read related blog posts.
- Or install with
`cabal install unamb`. - Get the code repository.

See also the lub package, which extends unamb's usefulness with non-flat types.

## [edit] 2 Issues

Although semantically very simple, unamb has been quite tricky to implement correctly and efficiently.

As of version 0.1.1, unamb requires ghc 6.10 or better.

As of version 0.1.6, unamb correctly handles recursive termination of sub-efforts and automatic restarting, but only with the GHC RTS fixes that first appeared (stably, by my testing) in GHC HEAD version 6.11.20090115. The problems and solution can be found in a few places:

- Email thread:
*Problem with unamb -- doesn't kill enough threads* - Blog post:
*Smarter termination for thread racing* - Email thread:
*Black hole detection and concurrency*

unamb seems to be working well in version 0.2.2, under GHC 6.10.3.