<commit_before>{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE LambdaCase        #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns      #-}

-- Module      : Gen.Templates
-- Copyright   : (c) 2013-2014 <NAME> <<EMAIL>>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : <NAME> <<EMAIL>>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)

module Gen.Templates where

import Control.Applicative
import Control.Error
import Gen.IO
import Gen.Types
import System.FilePath
import Text.EDE

data Templates = Templates
    { _tCabal      :: Template
    , _tService    :: Template
    , _tWaiters    :: Template
    , _tReadme     :: Template
    , _tExCabal    :: Template
    , _tExMakefile :: Template
    , _tProtocol   :: Protocol -> (Template, Template)
    }

loadTemplates :: FilePath -> Script Templates
loadTemplates d = do
    f  <- Templates
        <$> load "cabal"
        <*> load "service"
        <*> load "waiters"
        <*> load "readme"
        <*> load "example-cabal"
        <*> load "example-makefile"

    !x <- (,)
        <$> load "types-xml"
        <*> load "operation-xml"

    !j <- (,)
        <$> load "types-json"
        <*> load "operation-json"

    !q <- (,)
        <$> load "types-query"
        <*> load "operation-query"
<commit_msg>Strictness annotation for template loading<commit_after>{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE LambdaCase        #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns      #-}

-- Module      : Gen.Templates
-- Copyright   : (c) 2013-2014 <NAME> <<EMAIL>>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : <NAME> <<EMAIL>>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)

module Gen.Templates where

import Control.Applicative
import Control.Error
import Gen.IO
import Gen.Types
import System.FilePath
import Text.EDE

data Templates = Templates
    { _tCabal      :: Template
    , _tService    :: Template
    , _tWaiters    :: Template
    , _tReadme     :: Template
    , _tExCabal    :: Template
    , _tExMakefile :: Template
    , _tProtocol   :: Protocol -> (Template, Template)
    }

loadTemplates :: FilePath -> Script Templates
loadTemplates d = do
    !f <- Templates
        <$> load "cabal"
        <*> load "service"
        <*> load "waiters"
        <*> load "readme"
        <*> load "example-cabal"
        <*> load "example-makefile"

    !x <- (,)
        <$> load "types-xml"
        <*> load "operation-xml"

    !j <- (,)
        <$> load "types-json"
        <*> load "operation-json"

    !q <- (,)
        <$> load "types-query"
        <*> load "operation-query"

{'fraction_non_alphanumeric': 0.1364076104482425, 'fraction_numerical': 0.007739438890680426, 'mean_word_length': 2.095808383233533, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5968635', 'n_tokens_mistral': 1034, 'n_tokens_neox': 990, 'n_words': 266}