Returning Subrelation into Haskell

16 views
Skip to first unread message

Scholablade

unread,
Feb 19, 2026, 8:18:34 AM (9 days ago) Feb 19
to project-m36
Am using Project-m36 for a webapplication and so far so good, however am stuck with not knowing how to bring back a subrelation made via the group operation into Haskell. Trying to do so brings Atomable errors. For example,
The record type within the subrelation is as: 
data NaiveReturn  = MkNaiveReturn {description :: Text, example :: Text,tachelhitWord :: Text} deriving (Generic, Show, Atomable, Tupleable)

The Return type will be then: 
data Return = MkReturn {grammaticalType :: Text, subrel :: [NaiveReturn]} deriving (Generic, Show) deriving Tupleable

Using the fromTuple function brings fromAtom errors as:
[Mkreturn {grammaticalType = "(prep)", subrel = *** Exception: improper fromAtom [a]
CallStack

Thanks,

Scholablade

unread,
Feb 19, 2026, 1:30:26 PM (8 days ago) Feb 19
to project-m36
I should have mentioned that the relation would be  {description :: Text, example :: Text,tachelhitWord :: Text, grammaticalType :: Text} pregrouping by grammaticalType.

A.M.

unread,
Feb 19, 2026, 7:48:32 PM (8 days ago) Feb 19
to proje...@googlegroups.com
You are encountering a known limitation of derived Atomable instances in
that they cannot support subrelations. We struggled with how Atomable
would function with an optional subrelation type variable, but
ultimately gave up on trying to make it work. I'm open to suggestions on
how to improve it though- perhaps a separate Atomable instance for
nested relations or type family could resolve this?

To resolve your immediate issue without changes to Project:M36, you'll
need to implement your own Tupleable instance for MkReturn and Atomable
instance for NaiveReturn. I can help with that if you like, but an LLM
could probably generate it easily.

Keep in mind that Atomable and Tupleable are just utilities to save on
code. You could just as easily write:

executeDatabaseExpr session dbconn (Insert "rv" (MakeRelationFromExprs
Nothing [TupleExprs () [TupleExpr (M.fromList [("description",TextAtom
(description ret)), ("example", TextAtom (example ret)),...

Cheers,
M

OpenPGP_signature.asc

Scholablade

unread,
Feb 20, 2026, 2:23:01 PM (7 days ago) Feb 20
to project-m36
I would like some help on the manual instances of Atomable and Tupleable sincethe documentation on it is very sparse.

Thanks, 

A.M.

unread,
Feb 21, 2026, 11:02:41 PM (6 days ago) Feb 21
to proje...@googlegroups.com
On 2/20/26 14:23, Scholablade wrote:
> I would like some help on the manual instances of Atomable and Tupleable
> sincethe documentation on it is very sparse.

Sure, take a look at the CustomTupleable example- it provides a manually
derived Tupleable instance with a nested relation, so it's virtually
identical to your use-case.

https://github.com/agentm/project-m36/blob/master/examples/CustomTupleable.hs

Cheers,
M


OpenPGP_signature.asc
Reply all
Reply to author
Forward
0 new messages