I’m using Spork for a simple web app that relies on a GraphQl server. In the client side, I’m using graphqlclient. The question isn’t really about these libraries but it helps with contextualising the issue.
Side effects in Spork are run within a natural transformation:
data AppEffect a = PersistInLocalStorage (Tuple String String) a | GraphQlQuery Token SelectionSet a runAppEffect :: AppEffect ~> Aff runAppEffect = case _ of -- implementation
The type variable
a can be the type for actions/messages as in this example.
a be a simple type for actions is limited. So, instead I used a function type:
a -> b; where
a is the result from some side effect and
b is the next action. With
graphqlQueryRequest being polymorphic, a more realistic
runAppEffect looks like:
type ToNextAction a = ∀ b. b -> a type GraphQlResponse a = ∀ b. Either (GraphQLError b) b -> a type QuerySelectionSet = ∀ b. SelectionSet Scope__RootQuery b data AppEffect a = PersistInLocalStorage (Tuple String String) (ToNextAction a) | GraphQlQuery QuerySelectionSet (GraphQlResponse a)
The issue here is with
QuerySelectionSet where the compiler complains about
b being a rigid type versus another concrete type that is used elsewhere in the update function. In the update function, the selection set has a type:
SelectionSet Scope__RootQuery (Array EntityJson)
I understand the issue but I’m not entirely sure about the best course of action.
Apologies if the explanation is inadequate. I’m also afraid I have to tag @natefaubion because he’s the maintainer of Spork