Skip to content

Instantly share code, notes, and snippets.

@SPY
Last active December 30, 2015 06:19
Show Gist options
  • Save SPY/7788533 to your computer and use it in GitHub Desktop.
Save SPY/7788533 to your computer and use it in GitHub Desktop.
instance GenServerState Command Int CounterState where
handle_call Get = gets counter
handle_cast Inc =
modify $ \st -> st { counter = counter st + 1 }
-- another instance for CounterState
instance GenServerState Command Float CounterState where
handle_call Get = gets (fromIntegral . counter)
handle_cast Inc =
modify $ \st -> st { counter = counter st + 1 }
-- compiler output
{-
tests/Test/GenServer.hs:22:10:
Functional dependencies conflict between instance declarations:
instance GenServerState Command Int CounterState
-- Defined at tests/Test/GenServer.hs:22:10
instance GenServerState Command Float CounterState
-- Defined at tests/Test/GenServer.hs:29:10
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment