News for hackers. Stuff that matters.
Re:Duck Wrapping by esmooov on Monday April 15, 2013 @09:07AM (#5551241)
Just want to point out that you could implement similar behavior in Haskell:

{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-}

class Concatable a b where concat' :: a -> b -> a

instance Concatable [a] a where concat' l xs = l ++ [xs]

instance Concatable [a] [a] where concat' l xs = l ++ xs

a :: [Int] a = [1,2,3]

b :: Int b = 4

c :: [Int] c = [4]

-- Main> concat' a b

-- [1,2,3,4]

-- Main> concat' a c

-- [1,2,3,4]

There are no comments on this comment yet.