Skip to content

Commit 91f430c

Browse files
committed
Expr.Types: org code for TH
1 parent 35812c9 commit 91f430c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Nix/Expr/Types.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
-- This module is a beginning of a deep embedding (term) of a Nix language into Haskell.
1818
-- Shallow/deep embedding brief:
1919
-- <https://web.archive.org/web/20201112031804/https://alessandrovermeulen.me/2013/07/13/the-difference-between-shallow-and-deep-embedding/>
20+
--
21+
-- (additiona info for dev): Big use of TemplateHaskell in the module requires proper (top-down) organization of declarations
2022
module Nix.Expr.Types where
2123

2224
import qualified Codec.Serialise as Serialise
@@ -114,6 +116,10 @@ type VarName = Text
114116

115117
-- ** @Params@
116118

119+
-- This uses an association list because nix XML serialization preserves the
120+
-- order of the param set.
121+
type ParamSet r = [(VarName, Maybe r)]
122+
117123
-- | @Params@ represents all the ways the formal parameters to a
118124
-- function can be represented.
119125
data Params r
@@ -141,13 +147,6 @@ instance IsString (Params r) where
141147
fromString = Param . fromString
142148

143149

144-
-- *** @ParamSet@
145-
146-
-- This uses an association list because nix XML serialization preserves the
147-
-- order of the param set.
148-
type ParamSet r = [(VarName, Maybe r)]
149-
150-
151150
-- ** @Antiquoted@
152151

153152
-- | 'Antiquoted' represents an expression that is either
@@ -505,17 +504,17 @@ data NExprF r
505504
, Show, Hashable, Hashable1
506505
)
507506

508-
-- | We make an `IsString` for expressions, where the string is interpreted
509-
-- as an identifier. This is the most common use-case...
510-
instance IsString NExpr where
511-
fromString = Fix . NSym . fromString
512-
513507

514508
-- *** @NExpr@
515509

516510
-- | The monomorphic expression type is a fixed point of the polymorphic one.
517511
type NExpr = Fix NExprF
518512

513+
-- | We make an `IsString` for expressions, where the string is interpreted
514+
-- as an identifier. This is the most common use-case...
515+
instance IsString NExpr where
516+
fromString = Fix . NSym . fromString
517+
519518
instance Serialise NExpr
520519

521520
instance TH.Lift NExpr where

0 commit comments

Comments
 (0)