Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Representing Field Families #6

alanz opened this Issue · 3 comments

2 participants


Another question. According to the Telehash protocol spec (, there can be multiple field in a given json message which are distinguished by a leading '+' character, followed by alpha-numerics. e.g. fields with names like "+end", or "+foo".

Without enumerating all possibilities, is there any way to gather these into a list or other structure in the underlying type?


data TeleHashEntry = TeleHashEntry 
                     { teleRing :: Int
                     , teleSee  :: Maybe [T.Text]
                     , teleBr   :: Int
                     , teleTo   :: T.Text
                     , teleLine :: Maybe T.Text
                     , teleHop  :: Maybe T.Text
                     , teleSignals::[ (T.Text,T.Text)] 
                     } deriving (Eq, Show)

telexJson = $(deriveIsos ''TeleHashEntry)

instance Json TeleHashEntry where
  grammar = telexJson . object
    ( prop "_ring"
    . prop ".see"
    . prop "_br"
    . prop "_to"
    . optionalProp "_line"
    . optionalProp "_hop"
    . prop "+????"      -- What should go here?

optionalProp :: Json a => String -> Iso (Object :- t) (Object :- Maybe a :- t)
optionalProp name = duck just . prop name <> duck nothing



Currently the closest you can get to this using the standard combinators is using rest which puts all the unprocessed properties on the stack as a map. When I've finished error reporting I'll give this some more thought. Perhaps a function like prop but with type Json a => (String -> Bool) -> Iso (Object :- t) (Object :- a :- t) would already be good enough for this.


I think getting all the unprocessed properties in a map will be fine for me, and gives me a convenient check that I am not missing anything.



Alright. :-) Closing this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.