Skip to content

Commit 440f886

Browse files
committed
misc: add example
1 parent af201ce commit 440f886

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

cassava-megaparsec.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ executable cassava-megaparsec-example
5959
hs-source-dirs: example
6060
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
6161
build-depends: base
62+
, cassava
6263
, cassava-megaparsec
6364
, text
65+
, vector
6466
default-language: Haskell2010
6567

6668
test-suite tests

example/Main.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE OverloadedStrings #-}
3+
{-# LANGUAGE TypeApplications #-}
4+
15
module Main where
26

7+
import Data.Csv hiding (decode, decodeByName, decodeByNameWith, decodeWith)
8+
import Data.Csv.Parser.Megaparsec (decode, decodeByName, decodeByNameWith, decodeWith)
9+
import Data.Vector (Vector)
10+
import GHC.Generics (Generic)
11+
12+
data Test = Test {a :: Char, b :: Char, c :: Char} deriving (Eq, Show, Generic)
13+
14+
instance FromRecord Test
15+
316
main :: IO ()
4-
main = putStrLn "This is a new example"
17+
main = do
18+
let res = decode @Test NoHeader "example" "a,ba,c\n"
19+
print res

0 commit comments

Comments
 (0)