1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Add list instance

This commit is contained in:
joshvera 2018-06-22 12:35:16 -04:00
parent 7170481a92
commit 710d7c0742
2 changed files with 16 additions and 3 deletions

View File

@ -33,6 +33,8 @@ message SrcLoc { string srcLocPackage = 1;
message ErrorSite { string errorMessage = 1;
SrcLoc errorLocation = 2;
}
message List { repeated Term listContent = 1;
}
message Error { repeated ErrorSite errorCallStack = 1;
repeated string errorExpected = 2;
string errorActual = 3;
@ -338,7 +340,8 @@ message Syntax { oneof syntax {Comment comment = 1;
LowPrecedenceOr lowPrecedenceOr = 77;
Module module = 78;
Require require = 79;
Send send = 80;}
Send send = 80;
List list = 81;}
}
message Term { Syntax syntax = 1;
}

View File

@ -138,8 +138,18 @@ instance Generate c all '[] where
instance (Element f all, c f, Generate c all fs) => Generate c all (f ': fs) where
generate each = each (Proxy @f) (natVal (Proxy @(ElemIndex f all))) `mappend` generate @c @all @fs each
instance Named1 []
instance Message1 []
instance Named1 [] where
nameOf1 _ = "List"
instance Message1 [] where
liftEncodeMessage encodeMessage num = foldMap (Encode.embedded num . encodeMessage (fieldNumber 1))
-- liftDecodeMessage decodeMessage = fmap toList (Decode.repeated (Decode.embedded' oneMsg))
-- where
-- oneMsg = decodeMessage (fieldNumber 1)
-- liftDotProto (_ :: Proxy [a]) = messageField (NestedRepeated (Named (Single (nameOf (Proxy @a))))) Nothing
liftDotProto (_ :: Proxy [a]) = [ Proto.DotProtoMessageField $ Proto.DotProtoField (fieldNumber 1) ty (Proto.Single "listContent") [] Nothing ]
where ty = (Proto.NestedRepeated (Proto.Named (Proto.Single (nameOf (Proxy @a)))))
-- Common