<commit_before>{-# LANGUAGE NamedFieldPuns #-}
module Philip.DSL
    ( desc
    , author
    , copyright
    , maintainer
    , name
    , version
    , licenseFile
    , stability
    , homepage
    , packageUrl
    , bugReports
    , synopsis
    , description
    , category
    , dataFiles
    , dataDir
    , extraSrcFiles
    , extraTmpFiles
    , extraDocFiles
    ) where

import           Control.Monad.State
import           Data.List.Split                 (splitOn)
import           Data.Version                    (Version (..))
import           Distribution.Package            (PackageIdentifier (..),
                                                  PackageName (..))
import           Distribution.PackageDescription (PackageDescription,
                                                  emptyPackageDescription)
import qualified Distribution.PackageDescription as PD

desc :: State PackageDescription a -> PackageDescription
desc = flip execState emptyPackageDescription

author, copyright, maintainer, version, name, licenseFile, stability,
  homepage, packageUrl, bugReports, synopsis, description, category
  :: String -> State PackageDescription ()
author x      = state $ \pd -> ((), pd { PD.author      = x })
copyright x   = state $ \pd -> ((), pd { PD.copyright   = x })
maintainer x  = state $ \pd -> ((), pd { PD.maintainer  = x })
licenseFile x = state $ \pd -> ((), pd { PD.licenseFile = x })
stability x   = state $ \pd -> ((), pd { PD.stability   = x })
homepage x    = state $ \pd -> ((), pd { PD.homepage    = x })
packageUrl x  = state $ \pd -> ((), pd { PD.pkgUrl      = x })
bugReports x  = state $ \pd -> ((), pd { PD.bugReports  = x })
synopsis x    = state $ \pd -> ((), pd { PD.synopsis    = x })
description x = state $ \pd -> ((), pd { PD.description = x })
category x    = state $ \pd -> ((), pd { PD.category    = x })

dataDir :: FilePath -> State PackageDescription()
dataDir x = state $ \pd -> ((), pd { PD.dataDir = x })

dataFiles, extraSrcFiles, extraTmpFiles, extraDocFiles
  :: [FilePath] -> State PackageDescription ()
dataFiles xs = state $ \pd -> ((), pd { PD.dataFiles = xs })
extraSrcFiles xs = state $ \pd -> ((), pd { PD.extraSrcFiles = xs })
extraTmpFiles xs = state $ \pd -> ((), pd { PD.extraTmpFiles = xs })
extraDocFiles xs = state $ \pd -> ((), pd { PD.extraDocFiles = xs })

version x    = state $ \pd -> ((), pd { PD.package    = update x (PD.package pd) })
  where
    -- TODO Update version tags
    update v PackageIdentifier{pkgName} = PackageIdentifier pkgName $ Version (parse v) []
    parse xs = map (\x -> read x :: Int) $ splitOn "." xs
name x = state $ \pd -> ((), pd { PD.package = update x (PD.package pd) })
  where
    update x PackageIdentifier{pkgVersion} = PackageIdentifier (PackageName x) pkgVersion<commit_msg>Update code format<commit_after>{-# LANGUAGE NamedFieldPuns #-}
module Philip.DSL
    ( desc
    , author
    , copyright
    , maintainer
    , name
    , version
    , licenseFile
    , stability
    , homepage
    , packageUrl
    , bugReports
    , synopsis
    , description
    , category
    , dataFiles
    , dataDir
    , extraSrcFiles
    , extraTmpFiles
    , extraDocFiles
    ) where

import           Control.Monad.State
import           Data.List.Split                 (splitOn)
import           Data.Version                    (Version (..))
import           Distribution.Package            (PackageIdentifier (..),
                                                  PackageName (..))
import           Distribution.PackageDescription (PackageDescription,
                                                  emptyPackageDescription)
import qualified Distribution.PackageDescription as PD

desc :: State PackageDescription a -> PackageDescription
desc = flip execState emptyPackageDescription

author, copyright, maintainer, version, name, licenseFile, stability,
  homepage, packageUrl, bugReports, synopsis, description, category
  :: String -> State PackageDescription ()
author x      = state $ \pd -> ((), pd { PD.author      = x })
copyright x   = state $ \pd -> ((), pd { PD.copyright   = x })
maintainer x  = state $ \pd -> ((), pd { PD.maintainer  = x })
licenseFile x = state $ \pd -> ((), pd { PD.licenseFile = x })
stability x   = state $ \pd -> ((), pd { PD.stability   = x })
homepage x    = state $ \pd -> ((), pd { PD.homepage    = x })
packageUrl x  = state $ \pd -> ((), pd { PD.pkgUrl      = x })
bugReports x  = state $ \pd -> ((), pd { PD.bugReports  = x })
synopsis x    = state $ \pd -> ((), pd { PD.synopsis    = x })
description x = state $ \pd -> ((), pd { PD.description = x })
category x    = state $ \pd -> ((), pd { PD.category    = x })
version x    = state $ \pd -> ((), pd { PD.package    = update x (PD.package pd) })
  where
    -- TODO Update version tags
    update v PackageIdentifier{pkgName} = PackageIdentifier pkgName $ Version (parse v) []
    parse xs = map (\x -> read x :: Int) $ splitOn "." xs
name x = state $ \pd -> ((), pd { PD.package = update x (PD.package pd) })
  where
    update x PackageIdentifier{pkgVersion} = PackageIdentifier (PackageName x) pkgVersion

dataDir :: FilePath -> State PackageDescription()
dataDir x = state $ \pd -> ((), pd { PD.dataDir = x })

dataFiles, extraSrcFiles, extraTmpFiles, extraDocFiles
  :: [FilePath] -> State PackageDescription ()
dataFiles xs = state $ \pd -> ((), pd { PD.dataFiles = xs })
extraSrcFiles xs = state $ \pd -> ((), pd { PD.extraSrcFiles = xs })
extraTmpFiles xs = state $ \pd -> ((), pd { PD.extraTmpFiles = xs })
extraDocFiles xs = state $ \pd -> ((), pd { PD.extraDocFiles = xs })
{'fraction_non_alphanumeric': 0.13754912468738836, 'fraction_numerical': 0.0, 'mean_word_length': 2.266627771295216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5728458', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1585, 'n_words': 489}