Created
December 26, 2017 18:42
-
-
Save chessai/d841ded63f03c27b36b46439a772c96e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- -*- coding: utf-8; mode: haskell; -*- | |
-- File: src/Silvi/Tutorial.hs | |
-- | |
-- License: | |
-- Copyright 2017 Daniel Cartwright | |
-- | |
-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
-- | |
-- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |
-- | |
-- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |
-- | |
-- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | |
-- | |
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
{-# OPTIONS_GHC -fno-warn-unused-imports #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TypeApplications #-} | |
-- | | |
-- Module : Silvi.Tutorial | |
-- Copyright : Copyright 2017 Daniel Cartwright | |
-- License : BSD3 | |
-- Maintainer : [email protected] | |
-- Stability : stable | |
module Silvi.Tutorial | |
( -- * Introduction | |
-- $introduction | |
-- * Defining Logs | |
-- $def_logs | |
-- * Sec2 | |
-- $sec2 | |
) where | |
import Silvi.Random (randLog, randLogExplicit) | |
import Silvi.Record (Field (..), SingField (..), Value (..)) | |
-------------------------------------------------------------------------------- | |
-- $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: | |
-- | |
-- @ | |
-- {-# LANGUAGE DataKinds #-} | |
-- {-# LANGUAGE OverloadedStrings #-} | |
-- {-# LANGUAGE TypeApplications #-} | |
-- @ | |
-- | |
-- And the following imports: | |
-- | |
-- @ | |
-- import Silvi.Random | |
-- import Silvi.Record | |
-- @ | |
-- | |
-- -- TODO For this tutorial, we will also use some other imports: | |
--------------------------------------------------------------------------------- | |
-- $def_logs | |
-- | |
-- > -- TestLog represents a Log consisting of just an IPv4 address and a URL. | |
-- > type TestLog = '[ FieldIp | |
-- > , FieldUrl | |
-- > ] | |
-- > | |
-- > -- 'randTestLog' now contains a TestLog with randomised inhabitants of the IPv4 and URL types. | |
-- > randTestLog :: Gen (Rec Value as) | |
-- > randTestLog = randLog @TestLog | |
-- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment