Skip to content

Instantly share code, notes, and snippets.

@LeifW
Created December 20, 2017 01:27
Show Gist options
  • Save LeifW/ce871f491d2e9a22162c3e1e7e3cd813 to your computer and use it in GitHub Desktop.
Save LeifW/ce871f491d2e9a22162c3e1e7e3cd813 to your computer and use it in GitHub Desktop.
Undefined in generating avro bytes.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Avro
import Data.Avro.Schema
data Thing = Thing { num :: Int }
thingSchema :: Schema
thingSchema = Record "Thing" Nothing [] Nothing Nothing
[fld "num" Int]
where fld nm ty = Field nm [] Nothing Nothing ty Nothing
instance HasAvroSchema Thing where
schema = pure thingSchema
instance ToAvro Thing where
toAvro p = record thingSchema
["num" .= num p]
dataset :: [Thing]
dataset = [Thing 5]
main :: IO ()
main = do
bytes <- encodeContainer [dataset]
print bytes
When run, gives:
```
Prelude.undefined
CallStack (from HasCallStack):
error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at src/Data/Avro/Encode.hs:100:33 in avro-0.2.0.0-7D9gyFVmhinCwIHovPxGOA:Data.Avro.Encode
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment