### changeset 13:88d6897c391a

Redefine Similar. reject function in data
author Yasutaka Higa Sat, 06 Sep 2014 11:03:34 +0900 158ae705cd16 116131b196bb similar.hs 1 files changed, 11 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
```--- a/similar.hs	Tue Sep 02 16:59:52 2014 +0900
+++ b/similar.hs	Sat Sep 06 11:03:34 2014 +0900
@@ -1,31 +1,21 @@
+data Similar a = Single a | Similar a (Similar a)

-data Similar a = (Eq a) => Similar a (a -> a) a
+same :: (Eq a) => Similar a -> a
+same (Single x)    = x
+same (Similar x s) = if x == (same s) then x else undefined

instance (Eq a) => Eq (Similar a) where
-  s == ss = same s == same ss
+    s == ss = (same s) == (same ss)

-same :: (Eq a) => Similar a -> a
-same (Similar x f y) = if (f x) == y then y else undefined
+instance Functor Similar where
+   fmap f (Single a)    = Single (f a)
+   fmap f (Similar a s) = Similar (f a) (fmap f s)
+
+{-

mu :: (Eq a) => Similar (Similar a) -> Similar a
mu (Similar a f b) = if ((f a) == b) then b else undefined

-class EqFunctor f where
-  eqmap :: (Eq a, Eq b) => (a -> b) -> f a -> f b
-
-instance EqFunctor Similar where
-  eqmap f s = Similar fs id fs
-    where fs = f \$ same s
-
-  (>>=) :: (Eq a, Eq b) => m a -> (a -> m b) -> m b
-  return ::(Eq a) =>  a -> m a
-