Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Critique My First Project - CampBX API Client (Pavan Rikhi)


----------------------------------------------------------------------

Message: 1
Date: Sat, 19 Jul 2014 03:57:25 -0400
From: Pavan Rikhi <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Critique My First Project - CampBX API
        Client
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hiya, so I've spent the last 2 months or so learning Haskell. I've
finished the UPenn course, LYAH and a little bit of RWH.

I wanted to get a project going so I tried making an API client for the
CampBX Bitcoin Market[1]. I started out by following along with the
FPComplete Mailchimp API Tutorial[2].

I'm asking you beautiful people for any feedback on it so I can be sure
that I'm on the right track here, stuff like code style/idioms, project
layout, public interface, implementation, docs, ideas for new features,
anything you want to tell me, etc.:

https://github.com/prikhi/campbx-haskell


Typical usage would be something like this[3]:

    main :: IO ()
    main = do
        cfg <- defaultCampBXConfig
        _   <- runCampBX cfg $ do
            totalAskVolume <- calculateAskVolume <$> getDepth
            liftIO . putStrLn $ "Total Ask Volume: " ++ show totalAskVolume
        return ()

    calculateAskVolume :: Depth -> BTCAmount
    calculateAskVolume depthList = sum . map askPrice . asks $ depthList
        where askPrice (Ask (_, q)) = q


There are still some things I want to work on:

* Define Asks and Bids[4] using Record Syntax. The JSON[5] for a Bid/Ask
  comes back as a 2 item Array but the generically derived instance[6]
  expects an object. I haven't completely wrapped my head around Aeson's
  Array parsing...
* Write tests. I'm imagining they would be more "given this JSON, make
  sure the data structure is created correctly" instead of
  property-based testing.
* Use something other than Doubles to represent Amounts + Prices. Is
  there a standard library for accurate math with decimals(I need up to
  8 decimal places)? I suppose I could always just use Integers to
  represent Satoshis(the smallest subunit of bitcoins).


Also I tried adding "default-extensions: OverloadedStrings" to the
.cabal file and removing the pragmas from the source files, but the
package wouldn't build :(


[1] https://campbx.com/api.php
[2] 
https://www.fpcomplete.com/school/to-infinity-and-beyond/competition-winners/interfacing-with-restful-json-apis
[3] https://github.com/prikhi/campbx-haskell/blob/master/bin/CampBXMain.hs
[4] 
https://github.com/prikhi/campbx-haskell/blob/master/src/Web/CampBX/Types.hs#L71
[5] http://sleepanarchy.com/p/K1wuSm
[6] 
https://github.com/prikhi/campbx-haskell/blob/master/src/Web/CampBX/Types.hs#L188
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: GnuPG Digital Signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140719/558b97cb/attachment-0001.sig>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 73, Issue 14
*****************************************

Reply via email to