1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Some where

import Data.Unique
import Control.Applicative
import Control.Monad
import Control.Monad.Fix

data Person = Person {
		name :: String,
		friends :: [Person],
		pid :: Unique
	}

instance Show Unique where
	show u = show $ hashUnique u

instance Show Person where
	show (Person name friends pid) = "Person " ++ show name ++ " " ++ show (map (\(Person name _ pid) -> (name, pid)) friends) ++ " " ++ show pid

friends1 = do
	(bob, joe) <- mfix (\ ~(bob,joe) -> do
			bob <- Person "Bob" [joe] <$> newUnique
			joe <- Person "Joe" [bob] <$> newUnique
			return (bob, joe)
		)
	return [bob, joe]