Joe Fredette wrote:
this is bounded, enumerable, but infinite.
The question is whether there are types like this. If so, we would need
a new class:
class Finite a where
allValues :: [a]
instance (Finite a,Eq b) => Eq (a -> b) where
p == q = fmap p allValues == fmap q allValues
instance (Finite a,Eq a) => Traversable (a -> b) where
sequenceA afb = fmap lookup
(sequenceA (fmap (\a -> fmap (b -> (a,b)) (afb a)) allValues))
where
lookup :: [(a,b)] -> a -> b
lookup (a,b):_ a' | a == a' = b
lookup _:r a' = lookup r a'
lookup [] _ = undefined
instance Finite () where
allValues = [()]
data Nothing
instance Finite Nothing where
allValues = []
--
Ashley Yakeley
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe