<commit_before>module HsToCoq.ConvertHaskell.Declarations.Notations (buildInfixNotations) where

import Data.Bifunctor

import           Data.Map.Strict (Map)
import qualified Data.Map.Strict as M

import HsToCoq.Coq.Gallina
import HsToCoq.Coq.Gallina.Util

import HsToCoq.ConvertHaskell.InfixNames

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

buildInfixNotations :: Map Ident Signature -> Op -> Ident -> [Notation]
buildInfixNotations sigs op def = [ uncurry (InfixDefinition op (Var def))
                                      . maybe (Nothing, Level 99) (first Just)
                                      $ sigFixity =<< M.lookup op sigs
                                  , NotationBinding $ NotationIdentBinding (infixToPrefix op) (Var def) ]<commit_msg>Hack: Hardcode ∘ as left assoc and level 40<commit_after>{-# LANGUAGE OverloadedStrings #-}
module HsToCoq.ConvertHaskell.Declarations.Notations (buildInfixNotations) where

import Data.Bifunctor

import           Data.Map.Strict (Map)
import qualified Data.Map.Strict as M

import HsToCoq.Coq.Gallina
import HsToCoq.Coq.Gallina.Util

import HsToCoq.ConvertHaskell.InfixNames

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

buildInfixNotations :: Map Ident Signature -> Op -> Ident -> [Notation]
buildInfixNotations sigs op def = [ uncurry (InfixDefinition op (Var def))
                                      . maybe hardCodedAssoc (first Just)
                                      $ sigFixity =<< M.lookup op sigs
                                  , NotationBinding $ NotationIdentBinding (infixToPrefix op) (Var def) ]
  where hardCodedAssoc | op == "∘" = (Just LeftAssociativity, Level 40)
                       | otherwise = (Nothing, Level 99)
{'fraction_non_alphanumeric': 0.1639528354856822, 'fraction_numerical': 0.004491858506457047, 'mean_word_length': 1.8062992125984252, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3228027', 'n_tokens_mistral': 514, 'n_tokens_neox': 485, 'n_words': 125}