You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- example :: Members '[State String, Error String] r => Sem r String
If I past the above example into a source file, resulting in:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
importData.FunctionimportPolysemyimportPolysemy.StateimportPolysemy.Errorexample::Members '[StateString, ErrorString] r=>SemrString
example =do
put "start"let throwing, catching ::Members '[StateString, ErrorString] r=>SemrString
throwing =do
modify (++"-throw")
throw "error"
get
catching =do
modify (++"-catch")
get
catch @String throwing (\ _ -> catching)
main = example
& runError
&fmap (eitheridid)
& evalState ""& runM
& (print=<<)
I get the following:
[nix-shell:~/hci]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3
[nix-shell:~/hci]$ ghc bootstrap.hs
[1 of 1] Compiling Main ( bootstrap.hs, bootstrap.o )
bootstrap.hs:24:8: error:
• Couldn't match type ‘Polysemy.Internal.Union.IndexOf'[State s0, Embed IO]
(Polysemy.Internal.Union.Found
'[State s0, Embed IO] (State String))’ with ‘State String’ arising from a use of ‘example’ The type variable ‘s0’ is ambiguous • In the first argument of ‘(&)’, namely ‘example’ In the first argument of ‘(&)’, namely ‘example & runError’ In the first argument of ‘(&)’, namely ‘example & runError & fmap (either id id)’ |24 | main = example | ^^^^^^^
The text was updated successfully, but these errors were encountered:
This adds some noise, which I'm not a huge fan of. However if I hadn't
had my cup of coffee and not tried reading the type error, I might have
pushed back "actually use polysemy in the real world" to "later".
Ideally I think I would have read the docs, but I suspect that "paste
examples verbatim into ghc source file without reading docs" is a
popular method to try libraries out.
Fixespolysemy-research#349
polysemy/src/Polysemy/Internal.hs
Line 95 in 3c73118
If I past the above example into a source file, resulting in:
I get the following:
The text was updated successfully, but these errors were encountered: