<commit_before>{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ViewPatterns #-}

module GHC.Util.FreeVars (
    vars', varss', pvars', freeVarSet'
  , Vars' (..), FreeVars'(..) , AllVars' (..)
  ) where

import "ghc-lib-parser" RdrName
import "ghc-lib-parser" HsTypes
import "ghc-lib-parser" OccName
import "ghc-lib-parser" Name
import "ghc-lib-parser" HsSyn
import "ghc-lib-parser" SrcLoc
import "ghc-lib-parser" Bag (bagToList)

import Data.Generics.Uniplate.Data ()
import Data.Generics.Uniplate.Operations
import Data.Monoid (Monoid(..))
import Data.Semigroup (Semigroup(..))
import Data.Set (Set)
import qualified Data.Set as Set

( ^+ ) :: Set OccName -> Set OccName -> Set OccName
( ^+ ) = Set.union
( ^- ) :: Set OccName -> Set OccName -> Set OccName
( ^- ) = Set.difference

-- See [Note : Spack leaks lurking here?] below.
data Vars' = Vars'{bound' :: Set OccName, free' :: Set OccName}

instance Semigroup Vars' where
    Vars' x1 x2 <> Vars' y1 y2 = Vars' (x1 ^+ y1) (x2 ^+ y2)

instance Monoid Vars' where
    mempty = Vars' Set.empty Set.empty
    mconcat vs = Vars' (Set.unions $ map bound' vs) (Set.unions $ map free' vs)

-- A type `a` is a model of `AllVars' a` if exists a function
-- `allVars'` for producing a pair of the bound and free varaiable
-- sets in a value of `a`.
class AllVars' a where<commit_msg>Avoid warnings<commit_after>{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ViewPatterns #-}

module GHC.Util.FreeVars (
    vars', varss', pvars', freeVarSet'
  , Vars' (..), FreeVars'(..) , AllVars' (..)
  ) where

import "ghc-lib-parser" RdrName
import "ghc-lib-parser" HsTypes
import "ghc-lib-parser" OccName
import "ghc-lib-parser" Name
import "ghc-lib-parser" HsSyn
import "ghc-lib-parser" SrcLoc
import "ghc-lib-parser" Bag (bagToList)

import Data.Generics.Uniplate.Data ()
import Data.Generics.Uniplate.Operations
import Data.Monoid
import Data.Semigroup
import Data.Set (Set)
import qualified Data.Set as Set
import Prelude


( ^+ ) :: Set OccName -> Set OccName -> Set OccName
( ^+ ) = Set.union
( ^- ) :: Set OccName -> Set OccName -> Set OccName
( ^- ) = Set.difference

-- See [Note : Spack leaks lurking here?] below.
data Vars' = Vars'{bound' :: Set OccName, free' :: Set OccName}

instance Semigroup Vars' where
    Vars' x1 x2 <> Vars' y1 y2 = Vars' (x1 ^+ y1) (x2 ^+ y2)

instance Monoid Vars' where
    mempty = Vars' Set.empty Set.empty
    mconcat vs = Vars' (Set.unions $ map bound' vs) (Set.unions $ map free' vs)

-- A type `a` is a model of `AllVars' a` if exists a function
-- `allVars'` for producing a pair of the bound and free varaiable
-- sets in a value of `a`.
class AllVars' a where
{'fraction_non_alphanumeric': 0.1504120879120879, 'fraction_numerical': 0.005494505494505495, 'mean_word_length': 3.6908212560386473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7215198', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1105, 'n_words': 320}