<commit_before>{-# LANGUAGE FlexibleContexts #-}

module HsToCoq.ConvertHaskell.Declarations.TypeSynonym (SynBody(..), convertSynDecl) where

import Prelude hiding (Num)

import Control.Lens

import GHC hiding (Name)

import HsToCoq.Coq.Gallina as Coq
import HsToCoq.Coq.Gallina.Util
import HsToCoq.Coq.FreeVars

import HsToCoq.ConvertHaskell.Monad
import HsToCoq.ConvertHaskell.Variables
import HsToCoq.ConvertHaskell.Type
import HsToCoq.ConvertHaskell.Parameters.Edits

--------------------------------------------------------------------------------

data SynBody = SynBody Ident [Binder] (Maybe Term) Term
             deriving (Eq, Ord, Read, Show)

instance FreeVars SynBody where
  freeVars (SynBody _name args oty def) = binding' args $ freeVars oty *> freeVars def

convertSynDecl :: ConversionMonad m
               => Located RdrName -> LHsTyVarBndrs RdrName -> LHsType RdrName
               -> m SynBody
convertSynDecl name args def  = do
  coqName <- freeVar $ unLoc name
  SynBody <$> freeVar (unLoc name)
          <*> convertLHsTyVarBndrs Coq.Explicit args
          <*> use (edits.typeSynonymTypes . at coqName . to (fmap Var))
          <*> convertLType def<commit_msg>[core-coq] Put type synonyms in the type scope<commit_after>{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}

module HsToCoq.ConvertHaskell.Declarations.TypeSynonym (SynBody(..), convertSynDecl) where

import Prelude hiding (Num)

import Control.Lens

import GHC hiding (Name)

import HsToCoq.Coq.Gallina as Coq
import HsToCoq.Coq.Gallina.Util
import HsToCoq.Coq.FreeVars

import HsToCoq.ConvertHaskell.Monad
import HsToCoq.ConvertHaskell.Variables
import HsToCoq.ConvertHaskell.Type
import HsToCoq.ConvertHaskell.Parameters.Edits

--------------------------------------------------------------------------------

data SynBody = SynBody Ident [Binder] (Maybe Term) Term
             deriving (Eq, Ord, Read, Show)

instance FreeVars SynBody where
  freeVars (SynBody _name args oty def) = binding' args $ freeVars oty *> freeVars def

convertSynDecl :: ConversionMonad m
               => Located RdrName -> LHsTyVarBndrs RdrName -> LHsType RdrName
               -> m SynBody
convertSynDecl name args def  = do
  coqName <- freeVar $ unLoc name
  SynBody <$> freeVar (unLoc name)
          <*> convertLHsTyVarBndrs Coq.Explicit args
          <*> use (edits.typeSynonymTypes . at coqName . to (fmap Var))
          <*> ((`InScope` "type") <$> convertLType def)
{'fraction_non_alphanumeric': 0.1471667346106808, 'fraction_numerical': 0.0, 'mean_word_length': 2.7580398162327717, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 22, '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': '7250428', 'n_tokens_mistral': 829, 'n_tokens_neox': 799, 'n_words': 207}