Comments (5)
Would you have an example of that, as in, how would it work for, say, Quote
?
from stocks.
Lets say we want to read the 'companyName' field of the Stats record, like this (from branch bug/no-lookup):
diff --git a/Tests/Main.hs b/Tests/Main.hs
index 9996609..0c185f4 100644
--- a/Tests/Main.hs
+++ b/Tests/Main.hs
@@ -95,3 +81,15 @@ testMultiBatch1 = TestCase
testMultiBatch2 = TestCase
(do result <- getBatch ["dps", "fb"] [OHLCQuery, CompanyQuery]
assertBool "" (result /= Nothing))
+
+
+-- fail
+testCorrectCompanyName = TestCase
+ (do result <- getBatchCompany "aapl" [StatsQuery, NewsQuery, CompanyQuery]
+ assertEqual "" (pickCompanyName result) "Apple Inc.")
+
+pickCompanyName :: Maybe Batch -> String
+pickCompanyName (Just (Batch {stats = st})) = pickCompanyName' st
+
+pickCompanyName' :: Maybe Stats -> String
+pickCompanyName' (Just (Stats {companyName = cname})) = cname
We can't do this, since 'companyName' is not unique:
/Users/kristiansallberg/Documents/stocks/Tests/Main.hs:95:32: error:
Ambiguous occurrence ‘companyName’
It could refer to either the field ‘companyName’,
imported from ‘Net.Stocks’ at Tests/Main.hs:5:1-17
or the field ‘companyName’,
imported from ‘Net.Stocks’ at Tests/Main.hs:5:1-17
or the field ‘companyName’,
imported from ‘Net.Stocks’ at Tests/Main.hs:5:1-17
|
95 | pickCompanyName' (Just (Stats {companyName = cname})) = cname
|
So the way I propose to fix this, is to put the data structure definitions in separate modules, so that they can be uniquely accessed. If you don't have some better solution :-)
edit Actually, it works fine if '{-# LANGUAGE DuplicateRecordFields #-}' is added to the files using our library. But it kind of sucks to have to use language extensions just to use this lib
from stocks.
Please see this 693aec3 for what it would look like with my proposal (for Stats). I guess another solution would be to make sure no record fields are duplicate, like "statusCompanyName" in Status
from stocks.
I see, thanks for the detailed explanation.
We can probably go ahead with your proposal, I don't have any other suggestions at this point, thanks for looking into it!
from stocks.
Fixed by factoring out data types to their own haskell modules
from stocks.
Related Issues (20)
- [develop] Fix so we are able to give params to the API HOT 1
- [develop] IEX Regulation SHO Threshold Securities List HOT 1
- [develop] IEX Short Interest List HOT 1
- [develop] Peers HOT 4
- [develop] Relevant HOT 1
- [develop] Implement time series
- [develop] Look at and implement Reference data HOT 1
- [testing] Create better tests
- [develop] IEX market data HOT 1
- [develop] IEX Stats
- [develop] IEX Markets (not the same as IEX Market Data)
- [develop] Use Text instead of String? HOT 2
- CI HOT 6
- Release 0.2.0.0 HOT 7
- [type system] relation between query parameters and results
- Add Changelog HOT 4
- Handle connection/404 errors HOT 6
- Release 0.2.0.1 HOT 2
- Adapt this code to the new IEX cloud API HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stocks.