fork(2) download
  1. {-# Language MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, IncoherentInstances, TypeFamilies, PatternGuards, FunctionalDependencies #-}
  2.  
  3. import Control.Monad
  4.  
  5. class MonadConcat m a b
  6.  
  7. where monadConcat :: a -> m b
  8.  
  9. instance (Monad m, MonadConcat m (m a) b) => MonadConcat m (m (m a)) b
  10.  
  11. where monadConcat x = x >>= monadConcat
  12.  
  13. instance (Monad m, a ~ b) => MonadConcat m (m a) b
  14.  
  15. where monadConcat = id
  16.  
  17.  
  18. main = do print $ monadConcat [[[123]],[[345]],[[222],[3333,5555]]]
  19. print $ monadConcat [2345]
  20.  
  21. print $ monadConcat (Just 123)
  22. print $ monadConcat (Just $ Just 345)
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:18:11: error:
    • Ambiguous type variables ‘m0’, ‘b0’ arising from a use of ‘print’
      prevents the constraint ‘(Show (m0 b0))’ from being solved.
      Probable fix: use a type annotation to specify what ‘m0’, ‘b0’ should be.
      These potential instances exist:
        instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
        instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’
        instance (Show a, Show b, Show c) => Show (a, b, c)
          -- Defined in ‘GHC.Show’
        ...plus 13 others
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In a stmt of a 'do' block:
        print $ monadConcat [[[123]], [[345]], [[222], [3333, 5555]]]
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }
      In an equation for ‘main’:
          main
            = do { print $ monadConcat [[...], ....];
                   print $ monadConcat [2345];
                   print $ monadConcat (Just 123);
                   .... }

prog.hs:18:19: error:
    • No instance for (MonadConcat m0 [[[t0]]] b0)
        arising from a use of ‘monadConcat’
    • In the second argument of ‘($)’, namely
        ‘monadConcat [[[123]], [[345]], [[222], [3333, 5555]]]’
      In a stmt of a 'do' block:
        print $ monadConcat [[[123]], [[345]], [[222], [3333, 5555]]]
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }

prog.hs:18:34: error:
    • Ambiguous type variable ‘t0’ arising from the literal ‘123’
      prevents the constraint ‘(Num t0)’ from being solved.
      Probable fix: use a type annotation to specify what ‘t0’ should be.
      These potential instances exist:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
        (use -fprint-potential-instances to see them all)
    • In the expression: 123
      In the expression: [123]
      In the expression: [[123]]

prog.hs:19:11: error:
    • Ambiguous type variables ‘m1’, ‘b1’ arising from a use of ‘print’
      prevents the constraint ‘(Show (m1 b1))’ from being solved.
      Probable fix: use a type annotation to specify what ‘m1’, ‘b1’ should be.
      These potential instances exist:
        instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
        instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’
        instance (Show a, Show b, Show c) => Show (a, b, c)
          -- Defined in ‘GHC.Show’
        ...plus 13 others
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In a stmt of a 'do' block: print $ monadConcat [2345]
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }
      In an equation for ‘main’:
          main
            = do { print $ monadConcat [[...], ....];
                   print $ monadConcat [2345];
                   print $ monadConcat (Just 123);
                   .... }

prog.hs:19:19: error:
    • No instance for (MonadConcat m1 [t1] b1)
        arising from a use of ‘monadConcat’
    • In the second argument of ‘($)’, namely ‘monadConcat [2345]’
      In a stmt of a 'do' block: print $ monadConcat [2345]
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }

prog.hs:19:32: error:
    • Ambiguous type variable ‘t1’ arising from the literal ‘2345’
      prevents the constraint ‘(Num t1)’ from being solved.
      Probable fix: use a type annotation to specify what ‘t1’ should be.
      These potential instances exist:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
        (use -fprint-potential-instances to see them all)
    • In the expression: 2345
      In the first argument of ‘monadConcat’, namely ‘[2345]’
      In the second argument of ‘($)’, namely ‘monadConcat [2345]’

prog.hs:21:11: error:
    • Ambiguous type variables ‘m2’, ‘b2’ arising from a use of ‘print’
      prevents the constraint ‘(Show (m2 b2))’ from being solved.
      Probable fix: use a type annotation to specify what ‘m2’, ‘b2’ should be.
      These potential instances exist:
        instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
        instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’
        instance (Show a, Show b, Show c) => Show (a, b, c)
          -- Defined in ‘GHC.Show’
        ...plus 13 others
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In a stmt of a 'do' block: print $ monadConcat (Just 123)
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }
      In an equation for ‘main’:
          main
            = do { print $ monadConcat [[...], ....];
                   print $ monadConcat [2345];
                   print $ monadConcat (Just 123);
                   .... }

prog.hs:21:19: error:
    • No instance for (MonadConcat m2 (Maybe a0) b2)
        arising from a use of ‘monadConcat’
    • In the second argument of ‘($)’, namely ‘monadConcat (Just 123)’
      In a stmt of a 'do' block: print $ monadConcat (Just 123)
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }

prog.hs:21:37: error:
    • Ambiguous type variable ‘a0’ arising from the literal ‘123’
      prevents the constraint ‘(Num a0)’ from being solved.
      Probable fix: use a type annotation to specify what ‘a0’ should be.
      These potential instances exist:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘Just’, namely ‘123’
      In the first argument of ‘monadConcat’, namely ‘(Just 123)’
      In the second argument of ‘($)’, namely ‘monadConcat (Just 123)’

prog.hs:22:11: error:
    • Ambiguous type variables ‘m3’, ‘b3’ arising from a use of ‘print’
      prevents the constraint ‘(Show (m3 b3))’ from being solved.
      Probable fix: use a type annotation to specify what ‘m3’, ‘b3’ should be.
      These potential instances exist:
        instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
        instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’
        instance (Show a, Show b, Show c) => Show (a, b, c)
          -- Defined in ‘GHC.Show’
        ...plus 13 others
        ...plus one instance involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In a stmt of a 'do' block: print $ monadConcat (Just $ Just 345)
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }
      In an equation for ‘main’:
          main
            = do { print $ monadConcat [[...], ....];
                   print $ monadConcat [2345];
                   print $ monadConcat (Just 123);
                   .... }

prog.hs:22:19: error:
    • No instance for (MonadConcat m3 (Maybe (Maybe a1)) b3)
        arising from a use of ‘monadConcat’
    • In the second argument of ‘($)’, namely
        ‘monadConcat (Just $ Just 345)’
      In a stmt of a 'do' block: print $ monadConcat (Just $ Just 345)
      In the expression:
        do { print $ monadConcat [[[...]], [[...]], ....];
             print $ monadConcat [2345];
             print $ monadConcat (Just 123);
             print $ monadConcat (Just $ Just 345) }

prog.hs:22:44: error:
    • Ambiguous type variable ‘a1’ arising from the literal ‘345’
      prevents the constraint ‘(Num a1)’ from being solved.
      Probable fix: use a type annotation to specify what ‘a1’ should be.
      These potential instances exist:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘Just’, namely ‘345’
      In the second argument of ‘($)’, namely ‘Just 345’
      In the first argument of ‘monadConcat’, namely ‘(Just $ Just 345)’
stdout
Standard output is empty