Skip to content

Passing around effectful actions #201

Answered by evanrelf
eddiemundo asked this question in Q&A
Discussion options

You must be logged in to vote

You could create an inject equivalent for your Env type, like this:

injectEnv :: Subset xs es => Env xs -> Env es
injectEnv env = Env {getInitialState = inject env.getInitialState}

And then you don't need to use Subset elsewhere. This compiles for me:

#!/usr/bin/env nix-shell
#!nix-shell -i ghcid -p ghcid "ghc.withPackages (p: with p; [ effectful effectful-core ])"

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GHC2021 #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE Overloade…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@eddiemundo
Comment options

@eddiemundo
Comment options

Comment options

You must be logged in to vote
1 reply
@eddiemundo
Comment options

Answer selected by eddiemundo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants