sync with repo

parent fcca5374
{-|
Module : Language.Grammars.AspectAG
Description : Main module, First-class attribute grammars
Copyright : (c) Juan García Garland, Marcos Viera, 2019
Copyright : (c) Juan García-Garland, Marcos Viera, 2019, 2020
License : GPL
Maintainer : jpgarcia@fing.edu.uy
Stability : experimental
......@@ -31,13 +31,14 @@ Portability : POSIX
{-# LANGUAGE AllowAmbiguousTypes #-}
module Language.Grammars.AspectAG (
module Language.Grammars.AspectAG,
module Language.Grammars.AspectAG.HList,
module Language.Grammars.AspectAG.Label,
module Language.Grammars.AspectAG.GenRecord,
module Language.Grammars.AspectAG.RecordInstances,
module Language.Grammars.AspectAG.TPrelude
) where
(.+:),
(.:+:),
syn, syndef, syndefM,
mod, synmod, synmodM,
at, lhs,
Label, Prod, NT, Child, (#.), (=.),
emptyAtt
) where
import Language.Grammars.AspectAG.HList
......@@ -634,6 +635,9 @@ knitAspect (prd :: Label prd) asp fc ip
in knit ctx (req ctx' (OpLookup prd ((mkAspect asp) ctx))) fc ip
-- use
-- class Use (att :: Att) (prd :: Prod) (nts :: [NT]) (a :: Type) sc
-- where
-- usechi :: Label att -> Label prd -> KList nts -> (a -> a -> a) -> ChAttsRec prd sc
......
......@@ -45,12 +45,25 @@ import GHC.TypeLits
type family a == b where
a == b = Equal a b
-- | Record data structure for generic records (Internal). The `c`
-- index indicates the kind of record (for each record instance, the
-- user should define an index). The `r` index represents the mapping
-- from labels to values. Labels are of kind `k'`. Values are still
-- polykinded (`k''`) since rich information can be statically
-- represented here (for instance, when a record of records, or a
-- record of Vectors is represented). `k'` must implement the 'CMP'
-- family, although it is not visible here for simplicity. Records are
-- built putting fields ordered according to the `CMP` result of its
-- labels. __This is not intended to be used to build records__
data Rec (c :: k) (r :: [(k', k'')]) :: Type where
EmptyRec :: Rec c '[]
ConsRec :: TagField c l v -> Rec c r -> Rec c ('( l, v) ': r)
-- doc: comentar diseño, y falta de LabelSet
EmptyRec :: Rec c '[] -- ^ empty record
ConsRec :: TagField c l v -> Rec c r -> Rec c ('( l, v) ': r) -- ^ `ConsRec`
-- takes a field (`TagField`) and a
-- | doc: comentar diseño, y falta de LabelSet
data TagField (cat :: k) (l :: k') (v :: k'') where
TagField :: Label c -> Label l -> WrapField c v -> TagField c l v
......@@ -100,7 +113,7 @@ data OpLookup' (b :: Ordering)
-- | wrapper instance
instance
(Require (OpLookup' (Cmp l l') c l ('( l', v) ': r)) ctx)
Require (OpLookup' (Cmp l l') c l ('( l', v) ': r)) ctx
=>
Require (OpLookup c l ('( l', v) ': r)) ctx where
type ReqR (OpLookup c l ('( l', v) ': r)) =
......@@ -200,7 +213,6 @@ instance
req ctx (OpUpdate' proxy label field (ConsRec tgf r)) =
ConsRec (TagField Label label field) r
instance
( Require (OpUpdate c l v r) ctx
, ( '(l', v') : r0) ~ a -- only to unify kinds
......
......@@ -77,14 +77,6 @@ type instance ShowRec Reco = "Record"
type instance ShowField Reco = "field named "
-- | ** Pattern Synonyms
-- pattern EmptyR :: Rec Reco '[]
-- pattern EmptyR = EmptyRec :: Rec Reco '[]
-- pattern ConsR :: Tagged l v -> Rec Reco xs -> Rec Reco ( '(l,v ) ': xs)
-- pattern ConsR lv r = lv .*. r
type Tagged = TagField Reco
pattern Tagged :: v -> Tagged l v
pattern Tagged v = TagField Label Label v
......
......@@ -41,6 +41,9 @@ import qualified Data.Set as S
import Control.Monad
import Language.Grammars.AspectAG
import Language.Grammars.AspectAG.GenRecord
import Language.Grammars.AspectAG.RecordInstances
import Language.Grammars.AspectAG.Label
import qualified Data.Kind as DK
......
......@@ -72,7 +72,7 @@ data TagField (cat :: k) (l :: k') (v :: k'') where
untagField :: TagField c l v -> WrapField c v
untagField (TagField lc lv v) = v
type family WrapField (c :: k') (v :: k) = ftype -- | ftype -> c
type family WrapField (c :: k') (v :: k) = ftype
{-
Node: We cannot encode the dependency {ftype, c} -> v since
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment