-
-
Save Odomontois/8f8b4e720d09fbec94a6fce01ada1178 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Stepik () where | |
class (Enum a, Bounded a, Eq a) => SafeEnum a where | |
ssucc :: a -> a | |
ssucc x | x == maxBound = minBound | |
| otherwise = succ x | |
spred :: a -> a | |
spred x | x == minBound = maxBound | |
| otherwise = pred x | |
newtype SEnum a = SEnum{ getSEnum :: a} deriving (Enum, Bounded, Eq) | |
instance (Enum a, Bounded a, Eq a) => SafeEnum (SEnum a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment