fork download
  1. {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}
  2.  
  3. class PipeFirst b f | f -> b where
  4. (|>) :: f -> (b -> c) -> c
  5.  
  6. instance PipeFirst b (a -> b) where
  7. (|>) = flip (.)
  8.  
  9. instance PipeFirst c (a -> b -> c) where
  10. (|>) = flip ((.).(.))
  11.  
  12. instance PipeFirst d (a -> b -> c -> d) where
  13. (|>) = flip ((.).(.).(.))
  14.  
  15. main = print $ (f |> g) 1 2 3
  16. where f x y z = x + y + z
  17. g = (*2)
  18.  
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:6:10:
    Functional dependencies conflict between instance declarations:
      instance PipeFirst b (a -> b) -- Defined at prog.hs:6:10
      instance PipeFirst c (a -> b -> c) -- Defined at prog.hs:9:10
      instance PipeFirst d (a -> b -> c -> d) -- Defined at prog.hs:12:10

prog.hs:9:10:
    Functional dependencies conflict between instance declarations:
      instance PipeFirst c (a -> b -> c) -- Defined at prog.hs:9:10
      instance PipeFirst d (a -> b -> c -> d) -- Defined at prog.hs:12:10
stdout
Standard output is empty