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