On Wednesday, March 8, 2017 at 1:43:56 AM UTC+1, Evgenii Moiseenko wrote:
>
> I was wondering how the implementation of map-like data structure should 
> look like in MiniKanren. I am writing an interpreter of imperative language 
> in MiniKanren and I need a data structure to represent a mappings between 
> variables and their values. 
>
> Is there any code that implements that ?
>

Sorry, I don't have a direct answer but I'd like to share my findings 
regarding this topic.

So, microkanren does support relational in my implementation but you always 
need to 
ask explicitly to cross a relation, which is translated by variable forming 
a cross in the
scheme expression. For instance the following:

(run* (strawberry) 
  (fresh is fresh?) 
    (fs fruit 'concept/name "fruit")
    (fs is 'relation/start fruit)
    (fs is 'relation "is")
    (fs is 'relation/end concept)))

the database doesn't know that a feature is another feature. Simply said, 
foreign keys
are represented as keys. If you follow foreign keys automatically, you 
don't know where
it ends it's like a http redirect (302) in the hole of the white rabbit.

That said, I think it could be made less painful using the unify procedure 
of feature strucutres,
does basically that:

(define-module (space-feature))


(define database (sf:open "memory://"))

(define fruit (add! database '((kind . concept)
                               (concept . fruit))))

(define strawberry  (add! database '((kind . concept)
                                     (concept . strawberry))))

(define strawberry-is-a-fruit (add! database `((kind . relation)
                                               (start . ,strawberry)
                                               (relation . is)
                                               (end . ,fruit))))

(define what-is-a-fruit (unify database `((kind . relation)
                                          (relation . is)
                                          (end . ,fruit))))

(pk (equals? what-is-a-fruit `(((kind . relation)
                                (relation . is)
                                (end . ,fruit)
                                (start . ,strawberry))))

(pk (equals? (ref strawberry) '((kind . concept)
                                (concept . strawberry))))


;; but also

(define what-is-a-fruit (unify database `((kind . relation)
                                          (relation . is)
                                          (end . (@ ((kind . concept)))))))


                         
(pk (equals? what-is-a-fruit `(((kind . relation)
                                (relation . is)
                                (end . ,fruit)
                                (start . (@ '((kind . concept)
                                              (concept . strawberry))))))))

That's kind of the "API" of GraphQL.

-- 
You received this message because you are subscribed to the Google Groups 
"minikanren" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/minikanren.
For more options, visit https://groups.google.com/d/optout.

Reply via email to