Mercurial > hg > Members > atton > similar_monad
changeset 9:41c71f67c103
Show ErrorMessage
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Sep 2014 11:48:53 +0900 (2014-09-02) |
parents | 6e0285628ead |
children | 7c7efee7891f |
files | similer.hs |
diffstat | 1 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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)