
10 Oct
2006
10 Oct
'06
4:04 p.m.
data Secret a = Secret {password :: String, value :: a}
classify :: String -> a -> Secret a classify = Secret
declassify :: String -> Secret a -> Maybe a declassify guess (Secret pw v) | guess == pw = Just v | otherwise = Nothing
Put that in a module, do not export the Secret data type, and you're good to go. I'm unsure what a Monad is giving you....
I was just curious if I could do that within a monad. If the answer to my question is "no, you can't", then I'll pick up the shattered pieces of my life and move on. :-)