Summary
Do you ever feel the need to test code involving bottoms (e.g. calls to the @error@ function), or code involving infinite values? Then this library could be useful for you. It is usually easy to get a grip on bottoms by showing a value and waiting to see how much gets printed before the first exception is encountered. However, that quickly gets tiresome and is hard to automate using e.g. QuickCheck (<http://www.cse.chalmers.se/~rjmh/QuickCheck/>). With this library you can do the tests as simply as the following examples show. Testing explicitly for bottoms: [@> isBottom (head [\])@] @True@ [@> isBottom bottom@] @True@ [@> isBottom (\\_ -> bottom)@] @False@ [@> isBottom (bottom, bottom)@] @False@ Comparing finite, partial values: [@> ((bottom, 3) :: (Bool, Int)) ==! (bottom, 2+5-4)@] @True@ [@> ((bottom, bottom) :: (Bool, Int)) <! (bottom, 8)@] @True@ Showing partial and infinite values (@\\\/!@ is join and @\/\\!@ is meet): [@> approxShow 4 $ (True, bottom) \\\/! (bottom, \'b\')@] @\"Just (True, \'b\')\"@ [@> approxShow 4 $ (True, bottom) \/\\! (bottom, \'b\')@] @\"(_|_, _|_)\"@ [@> approxShow 4 $ ([1..\] :: [Int\])@] @\"[1, 2, 3, _\"@ [@> approxShow 4 $ (cycle [bottom\] :: [Bool\])@] @\"[_|_, _|_, _|_, _\"@ Approximately comparing infinite, partial values: [@> approx 100 [2,4..\] ==! approx 100 (filter even [1..\] :: [Int\])@] @True@ [@> approx 100 [2,4..\] \/=! approx 100 (filter even [bottom..\] :: [Int\])@] @True@ The code above relies on the fact that @bottom@, just as @error \"...\"@, @undefined@ and pattern match failures, yield exceptions. Sometimes we are dealing with properly non-terminating computations, such as the following example, and then it can be nice to be able to apply a time-out: [@> timeOut' 1 (reverse [1..5\])@] @Value [5,4,3,2,1]@ [@> timeOut' 1 (reverse [1..\])@] @NonTermination@ The time-out functionality can be used to treat \"slow\" computations as bottoms: [@> let tweak = Tweak { approxDepth = Just 5, timeOutLimit = Just 2 }@] [@> semanticEq tweak (reverse [1..\], [1..\]) (bottom :: [Int\], [1..\] :: [Int\])@] @True@ [@> let tweak = noTweak { timeOutLimit = Just 2 }@] [@> semanticJoin tweak (reverse [1..\], True) ([\] :: [Int\], bottom)@] @Just ([],True)@ This can of course be dangerous: [@> let tweak = noTweak { timeOutLimit = Just 0 }@] [@> semanticEq tweak (reverse [1..100000000\]) (bottom :: [Integer\])@] @True@ Timeouts can also be applied to @IO@ computations: [@> let primes = unfoldr (\\(x:xs) -> Just (x, filter ((\/= 0) . (\`mod\` x)) xs)) [2..\]@] [@> timeOutMicro 100 (print $ filter ((== 1) . (\`mod\` 83)) primes)@] @[167,499,9NonTermination@ [@> timeOutMicro 100 (print $ take 6 $ filter ((== 1) . (\`mod\` 83)) primes)@] @[167,499,997,1163,1993NonTermination@ [@> timeOutMicro 100 (print $ take 6 $ filter ((== 1) . (\`mod\` 83)) primes)@] @[167,499,997,1163,1993,2657]@ [@ @] @Value ()@ For the underlying theory and a larger example involving use of QuickCheck, see the article \"Chasing Bottoms, A Case Study in Program Verification in the Presence of Partial and Infinite Values\" (<http://www.cse.chalmers.se/~nad/publications/danielsson-jansson-mpc2004.html>). The code has been tested using GHC. Most parts can probably be ported to other Haskell compilers, but this would require some work. The @TimeOut@ functions require preemptive scheduling, and most of the rest requires @Data.Generics@; @isBottom@ only requires exceptions, though.
Versions
v1.3.1.9 :: 0/1.3.1.9 :: gentoo
- Modified
- License
- MIT
- Keywords
- ~amd64 ~x86
- USE flags
- doc hscolour profile test
USE flags
General
- doc
- Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
- hscolour
- Include coloured haskell sources to generated documentation (dev-haskell/hscolour)
- profile
- Add support for software performance analysis (will likely vary from ebuild to ebuild)
- test
- Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
Dependencies
dev-haskell / cabal : A framework for packaging Haskell software
dev-haskell / hscolour : Colourise Haskell code
dev-haskell / mtl : Monad classes, using functional dependencies
dev-haskell / quickcheck : Automatic testing of Haskell programs
dev-haskell / random : random number library
dev-haskell / syb : Scrap Your Boilerplate
Runtime Dependencies
dev-haskell / mtl : Monad classes, using functional dependencies
dev-haskell / quickcheck : Automatic testing of Haskell programs
dev-haskell / random : random number library
dev-haskell / syb : Scrap Your Boilerplate
Change logs
- Repository mirror & CI · gentoo
Merge updates from master - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: drop old
Package-Manager: Portage-3.0.6, Repoman-3.0.1 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> - Repository mirror & CI · gentoo
Merge updates from master - Jakov Smolic · gentoo
dev-haskell/chasingbottoms: update homepage
Package-Manager: Portage-3.0.3, Repoman-3.0.0 Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> - Repository mirror & CI · gentoo
Merge updates from master - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: bump up to 1.3.1.9
Package-Manager: Portage-3.0.1, Repoman-2.3.23 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> - Repository mirror & CI · gentoo
Merge updates from master - Jakov Smolic · gentoo
dev-haskell/chasingbottoms: update homepage link
Package-Manager: Portage-2.3.99, Repoman-2.3.22 Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr> Signed-off-by: Aaron Bauman <bman@gentoo.org> - Repository mirror & CI · gentoo
Merge updates from master - Sergei Trofimovich · gentoo
*/*: destabilize dev-lang/ghc for all arches
dev-lang/ghc is a fast-moving target without much of stable API across major GHC releases. This makes stabilization process a fragile process. The change moves all haskell revdeps to pure ~arch. There are not many outside dev-haskell/*: - app-emulation/ganeti - app-text/pandoc - dev-util/bustle - dev-util/shellcheck - dev-vcs/darcs - x11-wm/xmonad/xmonad Existing stable haskell users are recommended to keyword used packages and all of dev-haskell/* to ease upgrades. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> - Repository mirror & CI · gentoo
Merge updates from master - Michał Górny · gentoo
*/*: Inline mirror://hackage and update URIs
This change inlines mirror://hackage in all ebuilds, and updates URIs to the modern form (old URIs redirect to that). The change has been made using the following command: find -name '*.ebuild' -exec sed -r -i \ -e 's@mirror://hackage/@https://hackage.haskell.org/@g' \ -e 's@https://hackage.haskell.org/packages/archive/([^/]*)/([^/]*)/@https://hackage.haskell.org/package/\1-\2/@g' \ -e '/hackage\.haskell\.org/s@\$\{PN}-\$\{PV}@${P}@g' \ -e '/hackage\.haskell\.org/s@\$\{MY_PN}-\$\{PV}@${MY_P}@g' \ -e '/hackage\.haskell\.org/s@\$\{PN}-\$\{MY_PV}@${MY_P}@g' \ {} + Signed-off-by: Michał Górny <mgorny@gentoo.org> - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: stable 1.3.1.2 for x86/amd64, bug #631138
Package-Manager: Portage-2.3.10, Repoman-2.3.3 RepoMan-Options: --include-arches="amd64 x86" - Robin H. Johnson · gentoo
Drop $Id$ per council decision in bug #611234.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: bump up to 1.3.1.2
Package-Manager: Portage-2.3.3, Repoman-2.3.1 - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: bump up to 1.3.0.14
Package-Manager: portage-2.2.28 - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: drop old
Package-Manager: portage-2.2.28 - Sergei Trofimovich · gentoo
dev-haskell/chasingbottoms: stable on amd64/x86, bug #554002
Package-Manager: portage-2.2.20 - Robin H. Johnson · gentoo
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed