Copyright | Copyright 2017 Daniel Cartwright |
---|---|
License | BSD3 |
Maintainer | dcartwright@layer3com.com |
Stability | stable |
Safe Haskell | None |
Language | Haskell2010 |
Introduction
This library allows you to generate random logs, as well as easily construct any sort of log you might yourself want.
In general, when using silvi
, you'll want the following language extensions:
{--} {--} {--}
And the following imports:
import Silvi.Random import Silvi.Record
Defining Log Formats
-- It is easy to define a log. -- A log is represented as a type-level list consisting of different fields. -- 'SimpleLog' represents a Log consisting of just an IPv4 address and a URL. type SimpleLog = '[ FieldIp , FieldUrl ]
Generating Random Logs
-- 'randSimpleLog' now contains a SimpleLog with randomised inhabitants of the IPv4 and URL types. randSimpleLog :: Gen (Rec Value as) randSimpleLog = randLog @SimpleLog -- 'main' will print out 1000 'SimpleLog's. main :: IO () main = printMany 1000 randSimpleLog