Hi,

I'm not sure what you are after, but:

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

Thanks

Neil


On 10/10/06, Seth Gordon <[EMAIL PROTECTED]> wrote:
Cale Gibbard wrote:
> Why not just:
>
> secret :: a -> Classification String a
> secret = Classification "xyzzy"
>
> The password string isn't part of the type, it doesn't even
> necessarily exist at compile time. You might have just got confused
> between type and data constructors for a moment.
>

But now I want to be able to process the secret monadically:

mySecret =
  secret "Jimmy Hoffa is buried under the 50-yd line in the Meadowlands"

do secretData <- mySecret
   return (length secretData)

How do I define "return" so that it will put the password back, and how
do I define "(>>=)" so that the password won't be accessible within the
do-block?
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to