# HG changeset patch # User Yasutaka Higa # Date 1409626133 -32400 # Node ID 41c71f67c103854f6dbb05693f09ca332cc03b4f # Parent 6e0285628ead8dae43500b2d6c681d8734abec85 Show ErrorMessage diff -r 6e0285628ead -r 41c71f67c103 similer.hs --- a/similer.hs Tue Sep 02 11:27:49 2014 +0900 +++ b/similer.hs Tue Sep 02 11:48:53 2014 +0900 @@ -1,4 +1,3 @@ -{-# LANGUAGE UndecidableInstances #-} data Similer a b = Similer a (a -> b) b instance Functor (Similer a) where @@ -22,10 +21,10 @@ plusTwo :: Int -> Int plusTwo x = x + 2 -same :: Eq b => Similer a b -> b -same (Similer x f y) = if (f x) == y then y else undefined +same :: (Show b, Eq b) => Similer a b -> b +same (Similer x f y) = if (f x) == y then y else (error ("not same :" ++ show y)) -similer :: Eq b => (a -> b) -> (a -> b) -> a -> b +similer :: (Show b, Eq b) => (a -> b) -> (a -> b) -> a -> b similer f g x = same $ Similer x g (f x)