I have a CSV file:

% head -5 arf.csv
ENERG_LO,ENERG_HI,SPECRESP
0.3000000, 0.3100000, 4.874343
0.3100000, 0.3200000, 14.82926
0.3200000, 0.3300000, 21.30229
0.3300000, 0.3400000, 28.51495

which I can read with Frames, and do basic manipulation, but I can't seem to select a column. Could this be a user issue (missing something or using the wrong symbol) or perhaps an IHaskell one?

In [1]:
-- Not all of these are needed, but better be safe than sorry

:set -XConstraintKinds
:set -XDataKinds
:set -XFlexibleContexts
:set -XPatternSynonyms
:set -XQuasiQuotes
:set -XScopedTypeVariables
:set -XTypeOperators
:set -XViewPatterns

In [2]:
-- Not sure I'm going to use all these
import qualified Control.Foldl as L
import qualified Data.Foldable as F

import Control.Applicative

import Data.Proxy (Proxy(..))

import Lens.Family

import Frames

In [3]:
tableTypes "ARF" "arf.csv"


As a side note: some of the auto-generated symbols here are visually jarring (to me, such as aRFParser) since the default name changes don't really match well with the all-upper-case approach the file has for column names.

In [4]:
arfStream = readTableOpt aRFParser "../data/arf.csv"

In [5]:
arf <- inCoreAoS arfStream :: IO (Frame ARF)


As a check things are working:

In [6]:
columnHeaders (Proxy :: Proxy ARF)

["ENERG_LO","ENERG_HI","SPECRESP"]
In [7]:
mapM_ print (take 3 (F.toList (view sPECRESP <$> arf)))  4.874343 14.82926 21.30229 In [8]: L.fold L.maximum (view sPECRESP <$> arf)

Just 672.1996
In [9]:
showFields (frameRow arf 0)

["0.3","0.31","4.874343"]

Now I'd like to select just the SPECRESP column. From the tutorial, I tried the following, but got a kind error:

In [10]:
select (Proxy::Proxy [SPECRESP]) $frameRow arf 0  Kind incompatibility when matching types: fs :: [*] [SPECRESP] :: * Expected type: proxy0 fs Actual type: Proxy [SPECRESP] Relevant bindings include it :: Record fs (bound at :1:1) In the first argument of ‘select’, namely ‘(Proxy :: Proxy [SPECRESP])’ In the expression: select (Proxy :: Proxy [SPECRESP]) In the expression: select (Proxy :: Proxy [SPECRESP])$ frameRow arf 0

Unsurprisingly I also get it when using a function (rather than type annotation):

In [11]:
sprespOnly :: ARF -> Record [SPECRESP]
sprespOnly = rcast

The first argument of ‘Record’ should have kind ‘[*]’, but ‘[SPECRESP]’ has kind ‘*’
In the type signature for ‘IHaskell184.sprespOnly’: interactive:IHaskell184.sprespOnly :: ARF -> Record [SPECRESP]

Am I wrong to think that I should be using the SPECRESP type/symbol here? The only other "obvious-to-me" symbol would be Specresp, but this isn't defined:

In [12]:
foo :: ARF -> Record [Specresp]
foo = rcast

Not in scope: type constructor or class ‘Specresp’
In [ ]: