You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class (Contravariant f) ⇒ MaybeH f where
maybeh ∷ (a → Maybe b) → f b → f a
instance MaybeH Predicate where
-- FIXME not sure `False` is the correct default value here
-- TODO compare with `Either () b` instance?
-- TODO could also just require `Monoid b` and use `mempty` in place of `False`
maybeh ∷ ∀ a b . (a → Maybe b) → Predicate b → Predicate a
{-
maybeh h (Predicate pᵇ) = Predicate pᵃ
where
pᵃ ∷ a → Bool
pᵃ = maybe False pᵇ . h
-}
-- maybeh h (Predicate pᵇ) = Predicate (maybe False pᵇ . h)
maybeh h (Predicate pᵇ) = h >$< Predicate (maybe False pᵇ)
And if that works, why stop there? See if something like the following makes sense.
data List a = Nil | Cons a (List a)
class (Contravariant f) ⇒ ListH f where
listh ∷ (a → List b) → f b → f a
But should probably consider both foldr and unfoldr destructors.
And then would need to consider how that might play out:
instance ListH Predicate where
listh ∷ ∀ a b . (a → List b) → Predicate b → Predicate a
listh h (Predicate pᵇ) = Predicate pᵃ
where
pᵃ ∷ Predicate a
-- pᵃ = Predicate (\a → null (filter pᵇ (h a))) -- not (any pᵇ (h a))
pᵃ = Predicate (null . filter pᵇ . h) -- not . any pᵇ . h
listh ∷ ∀ a b . (a → List b) → Equivalence b → Equivalence a
implying something like ∷ List b → List b → Bool so maybe equivalence of lists by length? So then I would imagine ∷ List b → List b → Ordering would then be comparing lists by length?
Activity
subttle commentedon Nov 17, 2019
Experiment:
subttle commentedon Dec 23, 2019
Another experiment:
subttle commentedon Dec 23, 2019
And if that works, why stop there? See if something like the following makes sense.
But should probably consider both
foldrandunfoldrdestructors.And then would need to consider how that might play out:
implying something like
∷ List b → List b → Boolso maybe equivalence of lists by length? So then I would imagine∷ List b → List b → Orderingwould then be comparing lists by length?