<commit_before>module Ferry.Compiler (evaluate) where

import Ferry.Data
-- import Ferry.Impossible

-- import Data.Convertible
import Database.HDBC

evaluate :: IConnection conn
         => conn                -- ^ The HDBC connection
         -> Exp
         -> IO Norm
evaluate = undefined<commit_msg>Monad for fresh names<commit_after>module Ferry.Compiler (evaluate) where

import Ferry.Data
import Ferry.Syntax
import Ferry.Compiler.Transform
-- import Ferry.Impossible

-- import Data.Convertible
import Database.HDBC

{-
N monad, version of the state monad that can provide fresh variable names.
-}
newtype N a = N (State Int a)

unwrapN :: N a -> State Int a
unwrapN (N s) = s

instance Functor N where
    fmap f a = N $ fmap f $ unwrapN a

instance Monad N where
    s >>= m = N (unwrapN s >>= unwrapN . m)
    return = N . return
    
instance Applicative N where
  pure  = return
  (<*>) = ap

freshVar :: N String
freshVar = N $ do
                i <- get
                put (i + 1)
                return $ "__fv" ++ show i
     
runN :: N a -> a
runN = fst . (flip runState 1) . unwrapN

evaluate :: IConnection conn
         => conn                -- ^ The HDBC connection
         -> Exp
         -> IO Norm
evaluate = undefined
{'fraction_non_alphanumeric': 0.09294871794871795, 'fraction_numerical': 0.0016025641025641025, 'mean_word_length': 2.1225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '7281585', 'n_tokens_mistral': 396, 'n_tokens_neox': 375, 'n_words': 142}