[Haskell-cafe] a monad for secret information

Seth Gordon sethg at ropine.com
Tue Oct 10 12:04:12 EDT 2006


> 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.  :-)


More information about the Haskell-Cafe mailing list