<commit_before>{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances,
 FunctionalDependencies, KindSignatures,
  MultiParamTypeClasses, NoImplicitPrelude,
  TypeOperators, UndecidableInstances  #-} 
{-# OPTIONS -Wall #-}
-- | A tensor algebra library. Main ingredients are :
-- 
-- 'Vec' and ':~' are data constructors for rank-1 tensor.
-- This is essentially a touple of objects of the same type.
-- 
-- 'Vector' is a class for rank-1 tensor.
--
-- 'Axis' is an object for accessing the tensor components.

module Language.Paraiso.Tensor
    (
     (:~)(..), Vec(..), Axis(..), (!),
     Vector(..), VectorRing(..),
     contract,
     Vec0, Vec1, Vec2, Vec3, Vec4
    ) where

import qualified Algebra.Additive as Additive
import qualified Algebra.Ring as Ring
import           Data.Typeable
import           Language.Paraiso.Failure
import           Language.Paraiso.Prelude

infixl 9 !
-- | a component operator.
(!) :: Vector v => v a -> Axis v -> a
v ! i  = component i v   

-- | data constructor for 0-dimensional tensor.
data Vec a 
  = Vec 
  deriving (Eq, Ord, Show, Read, Typeable)

-- | data constructor for constructing n+1-dimensional tensor
-- from n-dimensional tensor.
data (n :: * -> * ) :~ a 
  = (n a) :~ a 
  deriving (Eq, Ord, Show, Read)
infixl 3 :~


instance (Typeable a, Typeable (n a)) => Typeable (n :~ a) where
  typeOf (vx :~ x) = 
    mkTyConApp (mkTyCon "Language.Paraiso.Tensor.:~") 
      [typeOf vx, typeOf x]

instance Foldable Vec where
  foldMap = foldMapDefault
instance Functor Vec where
  fmap = fmapDefault
instance Traversable Vec where<commit_msg>Vector is not Typeable anymore. The last implementation was buggy, waiting for the new Typeable support in GHC 7.2.1 (or 7.4)<commit_after>{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances,
 FunctionalDependencies, KindSignatures,
  MultiParamTypeClasses, NoImplicitPrelude,
  TypeOperators, UndecidableInstances  #-} 
{-# OPTIONS -Wall #-}
-- | A tensor algebra library. Main ingredients are :
-- 
-- 'Vec' and ':~' are data constructors for rank-1 tensor.
-- This is essentially a touple of objects of the same type.
-- 
-- 'Vector' is a class for rank-1 tensor.
--
-- 'Axis' is an object for accessing the tensor components.

module Language.Paraiso.Tensor
    (
     (:~)(..), Vec(..), Axis(..), (!),
     Vector(..), VectorRing(..),
     contract,
     Vec0, Vec1, Vec2, Vec3, Vec4
    ) where

import qualified Algebra.Additive as Additive
import qualified Algebra.Ring as Ring
import           Language.Paraiso.Failure
import           Language.Paraiso.Prelude

infixl 9 !
-- | a component operator.
(!) :: Vector v => v a -> Axis v -> a
v ! i  = component i v   

-- | data constructor for 0-dimensional tensor.
data Vec a 
  = Vec 
  deriving (Eq, Ord, Show, Read)

-- | data constructor for constructing n+1-dimensional tensor
-- from n-dimensional tensor.
data (n :: * -> * ) :~ a 
  = (n a) :~ a 
  deriving (Eq, Ord, Show, Read)
infixl 3 :~


instance Foldable Vec where
  foldMap = foldMapDefault
instance Functor Vec where
  fmap = fmapDefault
instance Traversable Vec where
{'fraction_non_alphanumeric': 0.12034659820282413, 'fraction_numerical': 0.008664955070603338, 'mean_word_length': 3.074509803921569, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '1175401', 'n_tokens_mistral': 1040, 'n_tokens_neox': 989, 'n_words': 344}