WrapMonad
tells us that a Monad
implies Functor
, Applicative
instance Monad m => Functor (WrappedMonad m)
instance Monad m => Applicative (WrappedMonad m)
instance Monad m => Monad (WrappedMonad m)
{-# LANGUAGE KindSignatures, DataKinds, TemplateHaskell, GADTs, TypeFamilies, TypeOperators, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, UndecidableInstances, QuantifiedConstraints, ConstraintKinds, PolyKinds, TypeApplications, ScopedTypeVariables #-} | |
import Data.Kind (Type) | |
import Data.Type.Equality | |
import Data.Maybe (isJust, isNothing) | |
import Generics.Kind hiding ((:~:)) | |
import Generics.Kind.TH | |
-- * Example |
a = a :: Eq b => () -- AllowAmbiguousTypes | |
a = proc b -> id -< b -- Arrows | |
a = let !b = () in b -- BangPatterns | |
a = 0b0 -- BinaryLiterals | |
a = id do 0 -- BlockArguments | |
foreign import capi "" a :: () | |
class A b where c :: Eq b => b -- ConstrainedClassMethods | |
type A = Eq -- ConstraintKinds | |
# -- CPP | |
import Data.Proxy; a = Proxy :: Proxy True -- DataKinds |
{-# LANGUAGE DataKinds, UndecidableInstances, ConstraintKinds, GADTs, FlexibleInstances, EmptyCase, LambdaCase #-} | |
{-# OPTIONS_GHC -Wall #-} | |
{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-} | |
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
import GHC.TypeLits | |
data Dict c where | |
Dict :: c => Dict c |
{-# LANGUAGE StaticPointers #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
import Data.Binary | |
import System.IO.Unsafe | |
import GHC.StaticPtr |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
-- | Fleshing out a new design for Generic1 that doesn't use Functor contexts | |
-- for derived instances, but rather Coercible. Why would we want this? | |
-- Consider this derived Generic1 instance: | |
-- | |
-- data T f a = T (f [a]) deriving Generic1 |
WrapMonad
tells us that a Monad
implies Functor
, Applicative
instance Monad m => Functor (WrappedMonad m)
instance Monad m => Applicative (WrappedMonad m)
instance Monad m => Monad (WrappedMonad m)
class (c x, d x) => (c :&: d) x | |
instance (c x, d x) => (c :&: d) x | |
instance (HasSuperClasses c, HasSuperClasses d, Distr (SuperClasses c)) => HasSuperClasses (c :&: d) where | |
type SuperClasses (c :&: d) = (c :&: d) ': SuperClasses c ++ SuperClasses d | |
superClasses = h superClasses superClasses | |
where | |
h :: forall x. c x :- FoldConstraints (SuperClasses c) x | |
-> d x :- FoldConstraints (SuperClasses d) x | |
-> (c :&: d) x :- FoldConstraints (SuperClasses (c :&: d)) x |