|
17 | 17 | -- This module is a beginning of a deep embedding (term) of a Nix language into Haskell. |
18 | 18 | -- Shallow/deep embedding brief: |
19 | 19 | -- <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 |
20 | 22 | module Nix.Expr.Types where |
21 | 23 |
|
22 | 24 | import qualified Codec.Serialise as Serialise |
@@ -114,6 +116,10 @@ type VarName = Text |
114 | 116 |
|
115 | 117 | -- ** @Params@ |
116 | 118 |
|
| 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 | + |
117 | 123 | -- | @Params@ represents all the ways the formal parameters to a |
118 | 124 | -- function can be represented. |
119 | 125 | data Params r |
@@ -141,13 +147,6 @@ instance IsString (Params r) where |
141 | 147 | fromString = Param . fromString |
142 | 148 |
|
143 | 149 |
|
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 | | - |
151 | 150 | -- ** @Antiquoted@ |
152 | 151 |
|
153 | 152 | -- | 'Antiquoted' represents an expression that is either |
@@ -505,17 +504,17 @@ data NExprF r |
505 | 504 | , Show, Hashable, Hashable1 |
506 | 505 | ) |
507 | 506 |
|
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 | | - |
513 | 507 |
|
514 | 508 | -- *** @NExpr@ |
515 | 509 |
|
516 | 510 | -- | The monomorphic expression type is a fixed point of the polymorphic one. |
517 | 511 | type NExpr = Fix NExprF |
518 | 512 |
|
| 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 | + |
519 | 518 | instance Serialise NExpr |
520 | 519 |
|
521 | 520 | instance TH.Lift NExpr where |
|
0 commit comments