
countable: Countable, Searchable, Finite, Empty classes. class Countable, for countable types class AtLeastOneCountable, for countable types that have at least one value class InfiniteCountable, for infinite countable types class Searchable, for types that can be searched over class Finite, for finite types class Empty, for empty types data Nothing, an empty type Also includes these orphan instances: instance (Searchable a,Eq b) => Eq (a -> b) instance (Finite a) => Foldable ((->) a) instance (Finite a) => Traversable ((->) a) instance (Show a,Finite a,Show b) => Show (a -> b) It turns out Searchable includes some infinite types. Specifically, countable implements this: instance (Countable c,Searchable s) => Searchable (c -> s) using the algorithm described here: http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/ I would welcome improvements. http://hackage.haskell.org/package/countable-0.1 cabal install countable darcs get http://code.haskell.org/countable/ See also this thread: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/73275

countable: Countable, Searchable, Finite, Empty classes. class Countable, for countable types class AtLeastOneCountable, for countable types that have at least one value class InfiniteCountable, for infinite countable types class Searchable, for types that can be searched over class Finite, for finite types class Empty, for empty types data Nothing, an empty type Also includes these orphan instances: instance (Searchable a,Eq b) => Eq (a -> b) instance (Finite a) => Foldable ((->) a) instance (Finite a) => Traversable ((->) a) instance (Show a,Finite a,Show b) => Show (a -> b) It turns out Searchable includes some infinite types. Specifically, countable implements this: instance (Countable c,Searchable s) => Searchable (c -> s) using the algorithm described here: http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/ I would welcome improvements. http://hackage.haskell.org/package/countable-0.1 cabal install countable darcs get http://code.haskell.org/countable/ See also this thread: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/73275 -- Ashley Yakeley

On Mon, 2010-09-06 at 03:54 -0700, Ashley Yakeley wrote:
countable: Countable, Searchable, Finite, Empty classes.
class Countable, for countable types class AtLeastOneCountable, for countable types that have at least one value class InfiniteCountable, for infinite countable types class Searchable, for types that can be searched over class Finite, for finite types class Empty, for empty types data Nothing, an empty type
Also includes these orphan instances:
instance (Searchable a,Eq b) => Eq (a -> b) instance (Finite a) => Foldable ((->) a) instance (Finite a) => Traversable ((->) a) instance (Show a,Finite a,Show b) => Show (a -> b)
It turns out Searchable includes some infinite types. Specifically, countable implements this:
instance (Countable c,Searchable s) => Searchable (c -> s)
using the algorithm described here:
http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/
I would welcome improvements.
http://hackage.haskell.org/package/countable-0.1 cabal install countable darcs get http://code.haskell.org/countable/
See also this thread: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/73275
Hmm. 1. Code formatting is very C#-like. At least for me it is hard to read the code that way (it IS matter of preference however) 2. countMaybeNext seems to need documentation. If I understand it correctly: countMaybeNext Nothing = 'minimalValue' countMaybeNext (Just x) = x + 1 Wouldn't be split it to: countNext :: a -> Maybe a initial :: Maybe a 3. Some methods need documentation. I don't know what recount actually do. Regards

On Mon, 2010-09-06 at 03:54 -0700, Ashley Yakeley wrote:
countable: Countable, Searchable, Finite, Empty classes.
class Countable, for countable types class AtLeastOneCountable, for countable types that have at least one value class InfiniteCountable, for infinite countable types class Searchable, for types that can be searched over class Finite, for finite types class Empty, for empty types data Nothing, an empty type
Also includes these orphan instances:
instance (Searchable a,Eq b) => Eq (a -> b) instance (Finite a) => Foldable ((->) a) instance (Finite a) => Traversable ((->) a) instance (Show a,Finite a,Show b) => Show (a -> b)
It turns out Searchable includes some infinite types. Specifically, countable implements this:
instance (Countable c,Searchable s) => Searchable (c -> s)
using the algorithm described here:
http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/
I would welcome improvements.
http://hackage.haskell.org/package/countable-0.1 cabal install countable darcs get http://code.haskell.org/countable/
See also this thread: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/73275
Hmm. 1. Code formatting is very C#-like. At least for me it is hard to read the code that way (it IS matter of preference however) 2. countMaybeNext seems to need documentation. If I understand it correctly: countMaybeNext Nothing = 'minimalValue' countMaybeNext (Just x) = x + 1 Wouldn't be split it to: countNext :: a -> Maybe a initial :: Maybe a 3. Regards

On Mon, 6 Sep 2010, Ashley Yakeley wrote:
countable: Countable, Searchable, Finite, Empty classes.
class Countable, for countable types class AtLeastOneCountable, for countable types that have at least one value class InfiniteCountable, for infinite countable types class Searchable, for types that can be searched over class Finite, for finite types class Empty, for empty types data Nothing, an empty type
Also includes these orphan instances:
instance (Searchable a,Eq b) => Eq (a -> b) instance (Finite a) => Foldable ((->) a) instance (Finite a) => Traversable ((->) a) instance (Show a,Finite a,Show b) => Show (a -> b)
Why must the domain be finite? I think infinite Strings produced by Show are not a problem, since the result of 'show infiniteList' is also infinite.

On Mon, 06 Sep 2010 03:46:18 -0700, Ashley Yakeley
countable: Countable, Searchable, Finite, Empty classes.
class Countable, for countable types class AtLeastOneCountable, for countable types that have at least one value class InfiniteCountable, for infinite countable types class Searchable, for types that can be searched over class Finite, for finite types class Empty, for empty types data Nothing, an empty type
Also includes these orphan instances:
instance (Searchable a,Eq b) => Eq (a -> b) instance (Finite a) => Foldable ((->) a) instance (Finite a) => Traversable ((->) a) instance (Show a,Finite a,Show b) => Show (a -> b)
Could you put these instances in a dedicated module? In the same vein I would like to have a newtype wrapper over functions were intention is to be used extensionally. Nice package BTW! -- Nicolas Pouillard http://nicolaspouillard.fr
participants (4)
-
Ashley Yakeley
-
Henning Thielemann
-
Maciej Piechotka
-
Nicolas Pouillard