<commit_before>{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures             #-}
{-# LANGUAGE LambdaCase                 #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE RoleAnnotations            #-}

-- Module      : Network.AWS.Data.Internal.List
-- Copyright   : (c) 2013-2014 <NAME> <<EMAIL>>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : <NAME> <<EMAIL>>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)

module Network.AWS.Data.Internal.List where

import           Control.Applicative
import           Control.Lens                      hiding (coerce)
import           Control.Monad
import           Data.Aeson
import           Data.Coerce
import           Data.Foldable                     (Foldable)
import           Data.List.NonEmpty                (NonEmpty(..))
import qualified Data.List.NonEmpty                as NonEmpty
import           Data.Monoid
import           Data.Semigroup                    (Semigroup)
import           Data.Traversable
import qualified Data.Vector                       as Vector
import           GHC.Exts
import           GHC.TypeLits
import           Network.AWS.Data.Internal.Flatten
import           Network.AWS.Data.Internal.Query
import           Network.AWS.Data.Internal.XML

newtype List (e :: Symbol) a = List { list :: [a] }
    deriving (Eq, Ord, Show, Semigroup, Monoid)

newtype List1 (e :: Symbol) a = List1 { list1 :: NonEmpty a }
    deriving (Eq, Ord, Show, Semigroup)

type role List  phantom representational
type role List1 phantom representational

_List :: (Coercible a b, Coercible b a) => Iso' (List e a) [b]
_List = iso (coerce . list) (List . coerce)

_List1 :: (Coercible a b, Coercible b a) => Iso' (List1 e a) (NonEmpty b)
_List1 = iso (coerce . list1) (List1 . coerce)<commit_msg>Intepreting symbols for location named collections<commit_after>{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures             #-}
{-# LANGUAGE LambdaCase                 #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE RoleAnnotations            #-}

{-# LANGUAGE ScopedTypeVariables            #-}


-- Module      : Network.AWS.Data.Internal.List
-- Copyright   : (c) 2013-2014 <NAME> <<EMAIL>>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : <NAME> <<EMAIL>>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)

module Network.AWS.Data.Internal.List where

import           Control.Applicative
import           Control.Lens                      hiding (coerce)
import           Control.Monad
import           Data.Aeson
import           Data.Coerce
import           Data.Foldable                     (Foldable)
import           Data.List.NonEmpty                (NonEmpty(..))
import qualified Data.List.NonEmpty                as NonEmpty
import           Data.Monoid
import           Data.Proxy
import           Data.Semigroup                    (Semigroup)
import           Data.Text                         (Text)
import qualified Data.Text                         as Text
import           Data.Traversable
import qualified Data.Vector                       as Vector
import           GHC.Exts
import           GHC.TypeLits
import           Network.AWS.Data.Internal.Flatten
import           Network.AWS.Data.Internal.Query
import           Network.AWS.Data.Internal.XML

newtype List (e :: Symbol) a = List { list :: [a] }
    deriving (Eq, Ord, Show, Semigroup, Monoid)

type role List  phantom representational

_List :: (Coercible a b, Coercible b a) => Iso' (List e a) [b]
_List = iso (coerce . list) (List . coerce)

listE :: forall e a. KnownSymbol e => List e a -> Text
listE _ = Text.pack (symbolVal (Proxy :: Proxy e))

newtype List1 (e :: Symbol) a = List1 { list1 :: NonEmpty a }
    deriving (Eq, Ord, Show, Semigroup)

type role List1 phantom representational

_List1 :: (Coercible a b, Coercible b a) => Iso' (List1 e a) (NonEmpty b)
_List1 = iso (coerce . list1) (List1 . coerce)

list1E :: forall e a. KnownSymbol e => List1 e a -> Text
list1E _ = Text.pack (symbolVal (Proxy :: Proxy e))

-- list1E :: List1 e a -> Text
-- list1E = Text.pack . symbolVal

{'fraction_non_alphanumeric': 0.10087252606937647, 'fraction_numerical': 0.010214939348797617, 'mean_word_length': 1.9048207663782448, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 24, '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': '4141234', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1379, 'n_words': 432}