[Haskell-cafe] oauth in haskell - reviewers?

Alexander Dunlap alexander.dunlap at gmail.com
Sun Aug 23 14:13:27 EDT 2009

On Sun, Aug 23, 2009 at 9:25 AM, Diego Souza<dsouza at bitforest.org> wrote:
> Hi Alex,
>> - In the Token datatype, you can automatically create the accessor
>> functions (oath_token, etc.) by using named fields:
> I though about that too and I was not sure about what to do. The reason
> I didn't use it is because I don't export the value constructors of
> Token type, that is why I created the access functions explicitly.

I'm pretty sure you can export just the access functions and not the
data constructors. They're just ordinary functions with a bit of
syntactic sugar, so they can be exported even if the constructors

>> - I think you can use join from Control.Monad and functions from
>> Control.Applicative in your "response" function to make it quite a bit
>> cleaner.
> To be honest I'm not familiar with Control.Applicative at all.  I'll
> read about it and see if I can figure how to do this.
> A quick search pointed me to this:
> http://www.soi.city.ac.uk/~ross/papers/Applicative.html
> Is there any other resources you would suggest me to read?

The rule of thumb I use is that you can replace

foo = do
  x1 <- action1
  x2 <- action2
  x3 <- action3
  xn <- actionn
  return (bar x1 x2 x3 ... xn)


foo = bar <$> action1 <*> action2 <*> action3 <*> ... <*> actionn

for any number of actions. (<$>) is a synonym for fmap and (<*>) is
the same as Control.Monad.ap if the applicative functor is also a
monad. (All monads can be made instances of Applicative, and most
[all?] of the standard ones are.)


More information about the Haskell-Cafe mailing list