import Data.Set (Set)
import Data.Text (Text)
import Data.Typeable
-import Symantic.Document (DocFrom(..))
import qualified Data.List as L
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
docType ::
forall src vs t d.
Semigroup d =>
- DocFrom (Doc.Word Char) d =>
- DocFrom (Doc.Word Text) d =>
+ Doc.From (Doc.Word Char) d =>
+ Doc.From (Doc.Word Text) d =>
Doc.Spaceable d =>
Doc.Colorable16 d =>
Config_Doc_Type ->
let iv = indexVar v in
case Map.lookup iv v2n of
Nothing -> error "[BUG] docType: variable name missing"
- Just n -> docFrom (Doc.Word n)
+ Just n -> Doc.from (Doc.Word n)
-- Const
go _v2n _po (TyConst _src _vs c@Const{}) =
(if isNameTyOp c then docParen else id) $
-- [] Const
go v2n _po (TyApp _ (TyConst _ _ f@Const{}) a)
| Just HRefl <- proj_ConstKi @(K []) @[] f =
- Doc.between (docFrom (Doc.Word '[')) (docFrom (Doc.Word ']')) $
+ Doc.between (Doc.from (Doc.Word '[')) (Doc.from (Doc.Word ']')) $
go v2n (infixB SideL 0, SideL) a
-- Infix Const
go v2n po (TyApp _ (TyApp _ (TyConst _ _ f@Const{}) a) b)
go v2n (op, SideR) b
where
d_op :: Text -> d
- d_op = Doc.yellower . docFrom . Doc.Word
+ d_op = Doc.yellower . Doc.from . Doc.Word
prettyConst :: forall k c. Const src (c::k) -> d
prettyConst c | Just HRefl <- proj_ConstKi @(K (#>)) @(#>) c = Doc.space <> d_op "=>" <> Doc.space
prettyConst c | Just HRefl <- proj_ConstKi @(K (#)) @(#) c = d_op "," <> Doc.space
docTypes ::
forall src vs ts d.
Semigroup d =>
- DocFrom (Doc.Word Char) d =>
- DocFrom (Doc.Word Text) d =>
+ Doc.From (Doc.Word Char) d =>
+ Doc.From (Doc.Word Text) d =>
Doc.Spaceable d =>
Doc.Colorable16 d =>
Config_Doc_Type ->
Types src vs ts -> d
docTypes conf tys =
- d_op (docFrom (Doc.Word '[')) <> go tys <> d_op (docFrom (Doc.Word ']'))
+ d_op (Doc.from (Doc.Word '[')) <> go tys <> d_op (Doc.from (Doc.Word ']'))
where
d_op = Doc.yellower
go :: forall xs. Types src vs xs -> d
go TypesZ = mempty
go (TypesS t0 (TypesS t1 ts)) =
docType conf 10 t0 <>
- d_op (docFrom (Doc.Word ',')) <> Doc.space <>
+ d_op (Doc.from (Doc.Word ',')) <> Doc.space <>
docType conf 10 t1 <>
go ts
go (TypesS t ts) = docType conf 10 t <> go ts
-- * Document 'Const'
docConst ::
Monoid d =>
- DocFrom (Doc.Word Char) d =>
- DocFrom (Doc.Word Text) d =>
+ Doc.From (Doc.Word Char) d =>
+ Doc.From (Doc.Word Text) d =>
Imports NameTy -> Const src c -> d
docConst imps c@Const{} =
docMod docNameTy $
mn@(m `Mod` n) = nameTyOf c
-- * Document 'NameTy'
-docNameTy :: DocFrom (Doc.Word Text) d => NameTy -> d
-docNameTy (NameTy t) = docFrom (Doc.Word t)
+docNameTy :: Doc.From (Doc.Word Text) d => NameTy -> d
+docNameTy (NameTy t) = Doc.from (Doc.Word t)
-- * Document 'Mod'
docMod ::
Monoid d =>
- DocFrom (Doc.Word Char) d =>
- DocFrom (Doc.Word Text) d =>
+ Doc.From (Doc.Word Char) d =>
+ Doc.From (Doc.Word Text) d =>
(a -> d) -> Mod a -> d
docMod a2d ([] `Mod` a) = a2d a
-docMod a2d (m `Mod` a) = docPathMod m <> (docFrom (Doc.Word '.')) <> a2d a
+docMod a2d (m `Mod` a) = docPathMod m <> (Doc.from (Doc.Word '.')) <> a2d a
-- * Document 'PathMod'
docPathMod ::
Monoid d =>
- DocFrom (Doc.Word Char) d =>
- DocFrom (Doc.Word Text) d =>
+ Doc.From (Doc.Word Char) d =>
+ Doc.From (Doc.Word Text) d =>
PathMod -> d
docPathMod (p::PathMod) =
mconcat $
- L.intersperse (docFrom (Doc.Word '.')) $
- (\(NameMod n) -> docFrom (Doc.Word n)) <$> p
+ L.intersperse (Doc.from (Doc.Word '.')) $
+ (\(NameMod n) -> Doc.from (Doc.Word n)) <$> p
-docParen :: Doc.Spaceable d => DocFrom (Doc.Word Char) d => d -> d
-docParen = Doc.between (docFrom (Doc.Word '(')) (docFrom (Doc.Word ')'))
+docParen :: Doc.Spaceable d => Doc.From (Doc.Word Char) d => d -> d
+docParen = Doc.between (Doc.from (Doc.Word '(')) (Doc.from (Doc.Word ')'))
{-
docModules ::