]> Git — Sourcephile - haskell/symantic.git/blob - symantic.cabal
Clarify names, and add commentaries.
[haskell/symantic.git] / symantic.cabal
1 author: Julien Moutinho <julm+symantic@autogeree.net>
2 bug-reports: Julien Moutinho <julm+symantic@autogeree.net>
3 build-type: Simple
4 cabal-version: >= 1.24
5 category: Language
6 -- data-dir: data
7 -- data-files:
8 description:
9 Library for composing, typing, compiling, transforming and interpreting
10 a custom DSL (Domain-Specific Language) expressing a subset of GHC's Haskell.
11 .
12 Main ideas are:
13 .
14 * To encode terms in the <http://okmij.org/ftp/tagless-final/ Tagless-Final> way
15 (aka. the /symantic/ way)
16 i.e. to use a /class/ to encode the /syntax/ of terms (eg. 'Sym_Bool')
17 and /class instances/ to encode their /semantics/ (eg. 'HostI' or 'TextI' instances).
18 /Lambda abstractions/ being handled by an higher-order approach,
19 meaning that it directly reuses GHC's internal machinery
20 to abstract or instantiate variables,
21 which I think is by far the most efficient and simplest way of doing it
22 (no DeBruijn encoding nor <https://hackage.haskell.org/package/bound bound>'s monads).
23 .
24 * To typecheck terms using a @(Type cs h)@ @GADT@ which acts
25 as a /singleton type/ for all Haskell type @h@
26 buildable from a /type-level list/ of /type constants/ @cs@
27 wrapped inside a @Proxy@
28 (eg. @[Proxy Bool, Proxy (->), Proxy Eq]@).
29 @TypeInType@ (introduced in GHC 8.0.1)
30 enabling 'Type' to also be @GADT@-like
31 in the kind of the Haskell type @h@ it encodes.
32 This making the /type application/ (':$')
33 giving us an /arrow kind/ for the Haskell /type constructor/
34 it applies an Haskell type to,
35 which avoids some tricky workarounds.
36 @Rank2Types@ enabling @GADT@s to be built from "raw data".
37 @ConstraintKinds@ enabling @h@ to be built from /classes/.
38 @PolyKinds@ enabling to avoid a lot of uses of 'Proxy'.
39 .
40 * To inject a type into a /type-level list/
41 or project a /type-level list/ onto a type,
42 to compose an /extensible data type/
43 (eg. the 'Token' @GADT@ gathering the 'TokenT' /data instances/,
44 that a parser can build and then give to 'compile').
45 This type-level programming requires @UndecidableInstances@,
46 but not @OverlappingInstances@.
47 I guess there is a similarity with
48 <http://dx.doi.org/10.1017/S0956796808006758 Data types à la carte>
49 (as exploited in <https://hackage.haskell.org/package/syntactic syntactic> for instance),
50 but not knowing much about them I can't tell,
51 I just came up using /type-level lists/ by hacking
52 <https://hackage.haskell.org/package/glambda glambda>'s @Elem@,
53 and now have no incentive to study and compare these techniques:
54 /type-level lists/ are simple enough.
55 .
56 * To recurse on a /type-level list/ through
57 /class instances/ to compose an /extensible class/
58 (eg. 'CompileR' gathering the 'CompileI' /class instances/,
59 or the more tricky 'TermO' /type-level list-zipper/
60 gathering 'Sym_of_Iface' /class instances/
61 while providing in scope the current 'Sym_of_Iface'
62 within each 'TermO' built in a 'CompileI' /class instance/).
63 .
64 * To use @DefaultSignatures@ to provide identity transformations of terms,
65 and thus avoid boilerplate code when a transformation
66 does not need to alter all semantics.
67 As explained in <https://ro-che.info/articles/2016-02-03-finally-tagless-boilerplate Reducing boilerplate in finally tagless style>.
68 .
69 There are a few examples of use in the @Test.hs@ files,
70 and shall be more one day in the reverse dependencies of this library.
71 .
72 Your comments, problem reports, or questions are welcome! :-)
73 .
74 TODO: there is no /type inferencing/ for now, only (hand written :( ) /type checking/.
75 This implies that the variable introduced
76 by a /lambda abstraction/ has to be explicitely typed,
77 and that terms must be called with enough arguments to typecheck,
78 be it term arguments (for instance
79 @(+) :: Num a => a -> a -> a@ needs at least one term argument to check @Num a@)
80 or type arguments (for instance
81 @return :: Monad m => a -> m a@ needs a type argument to check @Monad m@).
82 .
83 TODO: a lot of common terms should be added in @Compiling.*@ modules.
84 Maybe as separate packages to limit dependencies.
85 .
86 TODO: no transformation are implemented so far,
87 there should be some, at least as examples to demonstrate their power.
88 extra-source-files:
89 extra-tmp-files:
90 -- homepage: http://pad.autogeree.net/informatique/symantic/
91 license: GPL-3
92 license-file: COPYING
93 maintainer: Julien Moutinho <julm+symantic@autogeree.net>
94 name: symantic
95 stability: experimental
96 synopsis: Library for Typed Tagless-Final Higher-Order Composable DSL
97 tested-with: GHC==8.0.1
98 version: 3.20170104
99
100 Source-Repository head
101 location: git://git.autogeree.net/symantic
102 type: git
103
104 Library
105 default-extensions:
106 DataKinds
107 DefaultSignatures
108 FlexibleContexts
109 FlexibleInstances
110 InstanceSigs
111 MultiParamTypeClasses
112 OverloadedStrings
113 Rank2Types
114 ScopedTypeVariables
115 StandaloneDeriving
116 TypeApplications
117 TypeFamilies
118 TypeOperators
119 ghc-options: -Wall -fno-warn-tabs -fprint-explicit-kinds
120 default-language: Haskell2010
121 exposed-modules:
122 Language.Symantic
123 Language.Symantic.Compiling
124 Language.Symantic.Compiling.Applicative
125 Language.Symantic.Compiling.Bool
126 Language.Symantic.Compiling.Char
127 Language.Symantic.Compiling.Either
128 Language.Symantic.Compiling.Eq
129 Language.Symantic.Compiling.Foldable
130 Language.Symantic.Compiling.Functor
131 Language.Symantic.Compiling.IO
132 Language.Symantic.Compiling.If
133 Language.Symantic.Compiling.Int
134 Language.Symantic.Compiling.Integer
135 Language.Symantic.Compiling.Integral
136 Language.Symantic.Compiling.List
137 Language.Symantic.Compiling.Map
138 Language.Symantic.Compiling.Maybe
139 Language.Symantic.Compiling.Monad
140 Language.Symantic.Compiling.MonoFoldable
141 Language.Symantic.Compiling.MonoFunctor
142 Language.Symantic.Compiling.Monoid
143 Language.Symantic.Compiling.NonNull
144 Language.Symantic.Compiling.Num
145 Language.Symantic.Compiling.Ord
146 Language.Symantic.Compiling.Sequences
147 Language.Symantic.Compiling.Show
148 Language.Symantic.Compiling.Term
149 Language.Symantic.Compiling.Text
150 Language.Symantic.Compiling.Traversable
151 Language.Symantic.Compiling.Tuple2
152 Language.Symantic.Compiling.Unit
153 Language.Symantic.Interpreting
154 Language.Symantic.Interpreting.Dup
155 Language.Symantic.Interpreting.Host
156 Language.Symantic.Interpreting.Text
157 Language.Symantic.Lib.Data.Type.List
158 Language.Symantic.Lib.Data.Type.Peano
159 Language.Symantic.Parsing
160 Language.Symantic.Parsing.Token
161 Language.Symantic.Transforming
162 Language.Symantic.Transforming.Trans
163 Language.Symantic.Typing
164 Language.Symantic.Typing.Constant
165 Language.Symantic.Typing.Constraint
166 Language.Symantic.Typing.Family
167 Language.Symantic.Typing.Kind
168 Language.Symantic.Typing.Type
169 build-depends:
170 base >= 4.6 && < 5
171 , containers
172 , ghc-prim
173 , mono-traversable
174 , transformers
175 , text
176
177 Test-Suite symantic-test
178 type: exitcode-stdio-1.0
179 default-extensions:
180 DataKinds
181 FlexibleContexts
182 FlexibleInstances
183 MultiParamTypeClasses
184 OverloadedStrings
185 ScopedTypeVariables
186 TupleSections
187 TypeApplications
188 TypeFamilies
189 TypeOperators
190 default-language: Haskell2010
191 ghc-options: -Wall -fno-warn-tabs
192 -main-is Test
193 -- -fprint-explicit-kinds
194 hs-source-dirs: Language/Symantic
195 main-is: Test.hs
196 other-modules:
197 Compiling.Applicative.Test
198 Compiling.Bool.Test
199 Compiling.Foldable.Test
200 Compiling.Functor.Test
201 Compiling.Map.Test
202 Compiling.MonoFunctor.Test
203 Compiling.Term.Test
204 Compiling.Test
205 Parsing.Test
206 Typing.Test
207 build-depends:
208 base >= 4.6 && < 5
209 , containers
210 , mono-traversable
211 , transformers
212 , tasty >= 0.11
213 , tasty-hunit
214 , text
215 , symantic