<commit_before>-----------------------------------------------------------------------------
--
-- Module      :  Language.PureScript.TypeChecker.Monad
-- Copyright   :  (c) <NAME> 2013
-- License     :  MIT
--
-- Maintainer  :  <NAME> <<EMAIL>>
-- Stability   :  experimental
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------

{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances #-}

module Language.PureScript.TypeChecker.Monad where

import Language.PureScript.Types
import Language.PureScript.Kinds
import Language.PureScript.Names

import Control.Applicative
import Control.Monad.State
import Control.Monad.Error

import Control.Arrow ((***), first, second)

import qualified Data.Map as M

data NameKind = Value | Extern deriving Show

data TypeDeclarationKind = Data | ExternData | TypeSynonym deriving Show

data Environment = Environment
  { names :: M.Map (ModulePath, Ident) (PolyType, NameKind)
  , types :: M.Map (ModulePath, ProperName) (Kind, TypeDeclarationKind)
  , dataConstructors :: M.Map (ModulePath, ProperName) PolyType
  , typeSynonyms :: M.Map (ModulePath, ProperName) ([String], Type)
  , members :: M.Map (ModulePath, Ident) String
  } deriving (Show)

emptyEnvironment :: Environment
emptyEnvironment = Environment M.empty M.empty M.empty M.empty M.empty

data CheckState = CheckState { checkEnv :: Environment
                             , checkNextVar :: Int
                             , checkModulePath :: ModulePath
                             } deriving (Show)

newtype Check a = Check { unCheck :: StateT CheckState (Either String) a }
  deriving (Functor, Monad, Applicative, MonadPlus, MonadState CheckState, MonadError String)

getEnv :: Check Environment<commit_msg>add Alias constructor to NameKind<commit_after>-----------------------------------------------------------------------------
--
-- Module      :  Language.PureScript.TypeChecker.Monad
-- Copyright   :  (c) <NAME> 2013
-- License     :  MIT
--
-- Maintainer  :  <NAME> <<EMAIL>>
-- Stability   :  experimental
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------

{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances #-}

module Language.PureScript.TypeChecker.Monad where

import Language.PureScript.Types
import Language.PureScript.Kinds
import Language.PureScript.Names

import Control.Applicative
import Control.Monad.State
import Control.Monad.Error

import Control.Arrow ((***), first, second)

import qualified Data.Map as M

data NameKind = Value | Extern | Alias ModulePath Ident deriving Show

data TypeDeclarationKind = Data | ExternData | TypeSynonym deriving Show

data Environment = Environment
  { names :: M.Map (ModulePath, Ident) (PolyType, NameKind)
  , types :: M.Map (ModulePath, ProperName) (Kind, TypeDeclarationKind)
  , dataConstructors :: M.Map (ModulePath, ProperName) PolyType
  , typeSynonyms :: M.Map (ModulePath, ProperName) ([String], Type)
  , members :: M.Map (ModulePath, Ident) String
  } deriving (Show)

emptyEnvironment :: Environment
emptyEnvironment = Environment M.empty M.empty M.empty M.empty M.empty

data CheckState = CheckState { checkEnv :: Environment
                             , checkNextVar :: Int
                             , checkModulePath :: ModulePath
                             } deriving (Show)

newtype Check a = Check { unCheck :: StateT CheckState (Either String) a }
  deriving (Functor, Monad, Applicative, MonadPlus, MonadState CheckState, MonadError String)

getEnv :: Check Environment
{'fraction_non_alphanumeric': 0.18037357122943964, 'fraction_numerical': 0.002230275996654586, 'mean_word_length': 2.4009478672985782, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4143215', 'n_tokens_mistral': 979, 'n_tokens_neox': 954, 'n_words': 266}