77module Nix.Atoms where
88
99#ifdef MIN_VERSION_serialise
10- import Codec.Serialise
10+ import Codec.Serialise ( Serialise )
1111#endif
12- import Control.DeepSeq
13- import Data.Data
12+
13+ import Control.DeepSeq ( NFData )
14+ import Data.Data ( Typeable
15+ , Data )
1416import Data.Fixed ( mod' )
15- import Data.Hashable
17+ import Data.Hashable ( Hashable )
1618import Data.Text ( Text
1719 , pack
1820 )
19- import GHC.Generics
21+ import GHC.Generics ( Generic )
2022import Data.Binary ( Binary )
21- import Data.Aeson.Types ( FromJSON , ToJSON )
23+ import Data.Aeson.Types ( FromJSON
24+ , ToJSON
25+ )
2226
23- -- | Atoms are values that evaluate to themselves. This means that
27+ -- | Atoms are values that evaluate to themselves.
28+ -- In other words - this is a constructors that are literals in Nix.
29+ -- This means that
2430-- they appear in both the parsed AST (in the form of literals) and
25- -- the evaluated form.
31+ -- the evaluated form as themselves.
32+ -- Once HNix parsed or evaluated into atom - that is a literal
33+ -- further after, for any further evaluation it is in all cases stays
34+ -- constantly itself.
35+ -- "atom", Ancient Greek \( atomos \) - "indivisible" particle,
36+ -- indivisible expression.
2637data NAtom
2738 -- | An URI like @https://example.com@.
2839 = NURI Text
@@ -35,8 +46,17 @@ data NAtom
3546 | NBool Bool
3647 -- | Null values. There's only one of this variant: @null@.
3748 | NNull
38- deriving (Eq , Ord , Generic , Typeable , Data , Show , Read , NFData ,
39- Hashable )
49+ deriving
50+ ( Eq
51+ , Ord
52+ , Generic
53+ , Typeable
54+ , Data
55+ , Show
56+ , Read
57+ , NFData
58+ , Hashable
59+ )
4060
4161#ifdef MIN_VERSION_serialise
4262instance Serialise NAtom
@@ -46,7 +66,7 @@ instance Binary NAtom
4666instance ToJSON NAtom
4767instance FromJSON NAtom
4868
49- -- | Translate an atom into its nix representation.
69+ -- | Translate an atom into its Nix representation.
5070atomText :: NAtom -> Text
5171atomText (NURI t) = t
5272atomText (NInt i) = pack (show i)
0 commit comments