0 | ||| Types/interfaces featured in the specialisation API
 1 | ||| and implementations for them
 2 | module Deriving.SpecialiseData.Common
 3 |
 4 | import Deriving.Show
 5 | import Language.Reflection.Compat
 6 |
 7 | %language ElabReflection
 8 |
 9 | ---------------------------------
10 | --- SPECIALISATION ERROR TYPE ---
11 | ---------------------------------
12 |
13 | ||| Specialisation error
14 | public export
15 | data SpecialisationError : Type where
16 |   ||| Failed to extract polymorphic type name from task
17 |   TaskTypeExtractionError   : SpecialisationError
18 |   ||| Unused variable
19 |   UnusedVarError            : SpecialisationError
20 |   ||| Partial specification
21 |   PartialSpecError          : SpecialisationError
22 |   ||| Internal error
23 |   InternalError             : String -> SpecialisationError
24 |   ||| Lambda has unnamed arguments
25 |   UnnamedArgInLambdaError   : SpecialisationError
26 |   ||| Polymorphic type has unnamed arguments
27 |   UnnamedArgInPolyTyError   : Name -> SpecialisationError
28 |   ||| Failed to get TypeInfo
29 |   |||
30 |   ||| Can occur either due to trying to specialise a non-type invocation
31 |   ||| or due to not having the necessary TypeInfo in the NamesInfoInTypes instance
32 |   MissingTypeInfoError      : Name -> SpecialisationError
33 |
34 | %hint
35 | export
36 | showSE : Show SpecialisationError
37 | showSE = %runElab derive
38 |
39 | -------------------------------
40 | --- SPECIALISATION SETTINGS ---
41 | -------------------------------
42 |
43 |
44 | public export
45 | record SpecialisationParams where
46 |   [noHints]
47 |   constructor MkSpecParams
48 |   eraseConNames : Bool
49 |
50 | public export
51 | %defaulthint
52 | SpecialisationDefaults : SpecialisationParams
53 | SpecialisationDefaults = MkSpecParams
54 |   { eraseConNames = False
55 |   }
56 |
57 | public export
58 | interface NamespaceProvider (0 m : Type -> Type) where
59 |   constructor MkNSProvider
60 |   provideNS : m Namespace
61 |
62 | export
63 | Monad m => MonadTrans t => NamespaceProvider m => NamespaceProvider (t m) where
64 |   provideNS = lift provideNS
65 |
66 | export
67 | inNS : Monad m => Namespace -> NamespaceProvider m
68 | inNS ns = MkNSProvider $ pure ns
69 |
70 | export
71 | %defaulthint
72 | NoNS : Monad m => NamespaceProvider m
73 | NoNS = inNS (MkNS [])
74 |
75 |