packages feed

gigaparsec-0.3.1.0: benchmarks/Main.hs

{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE StandaloneDeriving, DeriveAnyClass, DeriveGeneric #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Main (main) where

import Gauge (defaultMain, bench, nf)
import Text.Gigaparsec (Parsec, Result, parse, atomic)
import Text.Gigaparsec.Char (string)
import Control.DeepSeq (NFData)
import Control.Applicative ((<|>))

p :: Parsec String
p = atomic (string "hello wold") <|> atomic (string "hi") <|> string "hello world"

deriving anyclass instance (NFData a, NFData e) => NFData (Result e a)

main :: IO ()
main = defaultMain [
    bench "consumption" $ nf (parse @String p) "hello world"
  ]