Idea from https://gist.github.com/Icelandjack/e1ddefb0d5a79617a81ee98c49fbbdc4
Works great for concrete types
data A = MkA
instance (Eq & Ord & Show & Arbitrary) A where
(==) :: A -> A -> Bool
MkA == MkA = True
Idea from https://gist.github.com/Icelandjack/e1ddefb0d5a79617a81ee98c49fbbdc4
Works great for concrete types
data A = MkA
instance (Eq & Ord & Show & Arbitrary) A where
(==) :: A -> A -> Bool
MkA == MkA = True
demoteMonoid :: (forall m. Monoid m => m) -> Semigroup m => Maybe m
demoteMonoid k = eval k where
eval :: MONOID m -> Semigroup m => Maybe m
eval = getOption . foldMap (Option . Just)
data MONOID a = NIL | SING a | MONOID a :<> MONOID a
deriving Foldable
instance Monoid (MONOID a) where
This could be synthesised
type family Methods (cls :: Type -> Constraint) (a :: Type) = (res :: [Pair Symbol Type]) | res -> a
type instance Methods A a = '["a" :- a]
type instance Methods B b = '["b" :- (b -> b)]
type instance Methods C c = '["c" :- (c -> Int), "b" :- (c -> c), "a" :- c]
data Pair a b = a :- b
Ticket #12001
.
pattern Singleton :: a -> NonEmpty a
pattern Singleton a <- (uncons -> (a, Nothing))
where Singleton a = a N.:| []
infixr 5 :|
{-# Language PatternSynonyms #-}
{-# Language ViewPatterns #-}
data DMonad m = DMonad
(forall a. a -> m a)
(forall a b. m a -> (a -> m b) -> m b)
(forall a. String -> m a)
pattern Open :: (forall a. a -> [a]) -> (forall a a'. [a] -> (a -> [a']) -> [a']) -> (forall a. String -> [a]) -> xxx
wip, spin-off gists: https://gist.github.com/Icelandjack/e42495341f6029aad8c7e4e4a12c34ce
Monad
gives Applicative
, Applicative
etc. gives Num
, Floating
, Fractional
(regardless of actual subclass relationship)WrapMonad
tells us that a Monad
implies Functor
, Applicative
instance Monad m => Functor (WrappedMonad m)
One of the best parts of Haskell is getting functionality for free
newtype T a = T_ (Compose [] Maybe a)
deriving (Functor, Foldable, Traversable, Applicative, Alternative)
{-# Complete T #-}
pattern T :: [Maybe a] -> T a
pattern T a = T_ (Compose a)