-- This template haskell splice explicitly specifies the name for the
-- inferred record type, column names, a separator string, and the
-- data file from which to infer the record type (i.e. what type
-- should be used to represent each column). The result of this splice
-- is included in an [[* Splice Dump][appendix]] below so you can flip
-- between the generated code and how it is used.

-- Since this data is far from the ideal CSV file, we have to tell
-- ~Frames~ how to interpret the data so that it can decide what data
-- type to use for each column. Having the types depend upon the data in
-- the given file is a useful exercise in this domain as the actual shape
-- of the data is of paramount importance during the early import and
-- exploration phases of data analysis.

-- We can load the module into =cabal repl= to see what we have so far.

-- #+BEGIN_EXAMPLE
-- λ> :i User
-- type User =
--   Record
--     '["user id" :-> Int, "age" :-> Int, "gender" :-> Text,
--       "occupation" :-> Text, "zip code" :-> Text]
-- #+END_EXAMPLE

-- This lets us perform a quick check that the types are basically what
-- we expect them to be.

-- We now define a streaming representation of the full data set. If the
-- data set is too large to keep in memory, we can process it as it
-- streams through RAM.

movieStream :: Producer User IO ()
movieStream = readTableOpt userParser "data/ml-100k/u.user"

movieStream :: Producer User IO ()
movieStream = readTableOpt userParser "data/ml-100k/u.user"
movieStream = readTableOpt userParser "data/ml-100k/u.user"