Last active
May 25, 2018 18:06
-
-
Save jchia/316dff3a66366ecf0efcb1aeac82ad11 to your computer and use it in GitHub Desktop.
Canonical Monoid instance & UndecidableInstances: Do I really need to turn on UndecidableInstances?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype CdRoot a = CdRoot (IO a) | |
cdRoot :: CdRoot a -> IO a | |
cdRoot (CdRoot x) = changeWorkingDirectory "/" >> x | |
instance Semigroup a => Semigroup (CdRoot a) where | |
CdRoot x <> CdRoot y = CdRoot $ x <> y | |
-- The constraint ‘Semigroup (CdRoot a)’ is no smaller than the instance head (Use UndecidableInstances to permit this) | |
instance (Semigroup (CdRoot a), Monoid a) => Monoid (CdRoot a) where | |
mempty = CdRoot mempty | |
mappend = (<>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment