module Proteome.Menu where

import Ribosome (Report, Rpc)
import Ribosome.Menu (MenuResult (Aborted, Error, Success))

handleResult ::
  Members [Rpc, Stop Report] r =>
  (a -> Sem r ()) ->
  MenuResult a ->
  Sem r ()
handleResult :: forall (r :: EffectRow) a.
Members '[Rpc, Stop Report] r =>
(a -> Sem r ()) -> MenuResult a -> Sem r ()
handleResult a -> Sem r ()
handle = \case
  Success a
a ->
    a -> Sem r ()
handle a
a
  MenuResult a
Aborted ->
    Sem r ()
forall (f :: * -> *). Applicative f => f ()
unit
  Error Text
e ->
    Report -> Sem r ()
forall e (r :: EffectRow) a. Member (Stop e) r => e -> Sem r a
stop (Text -> Report
forall a. IsString a => Text -> a
fromText Text
e)