Haskell Language Common GHC Language Extensions MultiParamTypeClasses

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

It's a very common extension that allows type classes with multiple type parameters. You can think of MPTC as a relation between types.

{-# LANGUAGE MultiParamTypeClasses #-}

class Convertable a b where
    convert :: a -> b

instance Convertable Int Float where
    convert i = fromIntegral i

The order of parameters matters.

MPTCs can sometimes be replaced with type families.



Got any Haskell Language Question?