<commit_before>{-# LANGUAGE TypeFamilies #-}
{-|
    Module      :  Numeric.AERN.Basics.Interval.Mutable
    Description :  mutable version of Interval
    Copyright   :  (c) <NAME>
    License     :  BSD3

    Maintainer  :  <EMAIL>
    Stability   :  experimental
    Portability :  portable

    Mutable version of Interval.
    
    This is a private module reexported publicly via its parent.
-}

module Numeric.AERN.Basics.Interval.Mutable where

import Numeric.AERN.Basics.Interval.Basics
import Numeric.AERN.Basics.Mutable

newtype MInterval e s = MInterval { unMInterval :: Interval (e s) }

instance (CanBeMutable e) => CanBeMutable (Interval e) where
    type Mutable (Interval e) = MInterval (Mutable e)
    makeMutable (Interval l h) = 
        do
        lM <- makeMutable l
        hM <- makeMutable h
        return $ MInterval $ Interval lM hM
    unsafeMakeMutable (Interval l h) = 
        do
        lM <- unsafeMakeMutable l
        hM <- unsafeMakeMutable h
        return $ MInterval $ Interval lM hM
    writeMutable (MInterval (Interval lM hM)) (Interval l h) =
        do
        writeMutable lM l
        writeMutable hM h
    unsafeWriteMutable (MInterval (Interval lM hM)) (Interval l h) =
        do
        unsafeWriteMutable lM l
        unsafeWriteMutable hM h
    readMutable (MInterval (Interval lM hM)) =
        do
        l <- readMutable lM 
        h <- readMutable hM 
        return $ Interval l h
    unsafeReadMutable (MInterval (Interval lM hM)) =
        do
        l <- unsafeReadMutable lM 
        h <- unsafeReadMutable hM 
        return $ Interval l h
<commit_msg>change mutable interval type to remove unnecessary indirection<commit_after>{-# LANGUAGE TypeFamilies #-}
{-|
    Module      :  Numeric.AERN.Basics.Interval.Mutable
    Description :  mutable version of Interval
    Copyright   :  (c) <NAME>
    License     :  BSD3

    Maintainer  :  <EMAIL>
    Stability   :  experimental
    Portability :  portable

    Mutable version of Interval.
    
    This is a private module reexported publicly via its parent.
-}

module Numeric.AERN.Basics.Interval.Mutable where

import Numeric.AERN.Basics.Interval.Basics
import Numeric.AERN.Basics.Mutable

data MInterval e s = 
    MInterval { left :: e s, right :: e s }

instance (CanBeMutable e) => CanBeMutable (Interval e) where
    type Mutable (Interval e) = MInterval (Mutable e)
    makeMutable (Interval l h) = 
        do
        lM <- makeMutable l
        hM <- makeMutable h
        return $ MInterval lM hM
    unsafeMakeMutable (Interval l h) = 
        do
        lM <- unsafeMakeMutable l
        hM <- unsafeMakeMutable h
        return $ MInterval lM hM
    writeMutable (MInterval lM hM) (Interval l h) =
        do
        writeMutable lM l
        writeMutable hM h
    unsafeWriteMutable (MInterval lM hM) (Interval l h) =
        do
        unsafeWriteMutable lM l
        unsafeWriteMutable hM h
    readMutable (MInterval lM hM) =
        do
        l <- readMutable lM 
        h <- readMutable hM 
        return $ Interval l h
    unsafeReadMutable (MInterval lM hM) =
        do
        l <- unsafeReadMutable lM 
        h <- unsafeReadMutable hM 
        return $ Interval l h

{'fraction_non_alphanumeric': 0.06816059757236227, 'fraction_numerical': 0.0006224712107065049, 'mean_word_length': 2.175889328063241, 'pattern_counts': {'":': 0, '<': 23, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2495305', 'n_tokens_mistral': 1041, 'n_tokens_neox': 957, 'n_words': 321}