How to define an eval function with an empty query type?

121 Views Asked by At

I have a query type data Query a

Given that Query has no constructors, how can I define an eval function of type:

eval :: Query ~> H.ComponentDSL State Query Void m

Would I have to add a constructor to Query?

1

There are 1 best solutions below

8
whbb On

Use type Query = Const Void and eval = absurd << un Const

type Query = Const Void = data Query a, They all have type Kind -> Kind, and have no constructor.

For eval = absurd <<< un Const match type Query ~> H.ComponentDSL State Query Void m. absurd :: forall a. Void -> a make sure return type match. un Const :: forall a b -> Const a b -> a make sure input type match (forall a. Query a -> Void)