Upgrade to newer libraries.

This commit is contained in:
Patrick Thomson 2019-09-04 17:00:07 -04:00
parent 63fd34c229
commit dbc52c4e55
4 changed files with 18 additions and 28 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.stack-work
.DS_Store
core-html/
dist
dist-newstyle/

View File

@ -13,7 +13,7 @@ extra-source-files: README.md
common shared
default-language: Haskell2010
ghc-options: -Wall -Werror -O2
ghc-options: -Wall -Werror -O2 -flate-specialise
build-depends: base >= 4.7 && < 5
library benchmark-signatures
@ -54,7 +54,7 @@ library instances-for-fused-effects
exposed-modules: Fused.Stateful
, Fused.StatefulExcept
, Fused.HTTP
build-depends: fused-effects >= 0.4.0.0
build-depends: fused-effects >= 0.5
library instances-for-freer-simple
import: shared
@ -67,18 +67,15 @@ library instances-for-freer-simple
library instances-for-polysemy
import: shared
hs-source-dirs: instances
ghc-options: -fplugin=Polysemy.Plugin
exposed-modules: Poly.Stateful
, Poly.StatefulExcept
, Poly.HTTP
build-depends: polysemy ^>= 0.2.1
, polysemy-plugin ^>= 0.2.0.0
build-depends: polysemy ^>= 1.2
benchmark effects-benchmarks
import: shared
type: exitcode-stdio-1.0
hs-source-dirs: src
ghc-options: -fplugin=Polysemy.Plugin
build-depends: benchmark-signatures
, instances-for-mtl
, instances-for-fused-effects

View File

@ -1,31 +1,23 @@
{-# LANGUAGE TypeOperators, FlexibleInstances, KindSignatures, MultiParamTypeClasses, DeriveFunctor, UndecidableInstances, GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveAnyClass, DeriveFunctor, DeriveGeneric, DerivingStrategies, FlexibleInstances, GeneralizedNewtypeDeriving,
KindSignatures, MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
module Fused.HTTP where
import Control.Effect
import Control.Effect.Sum
import Control.Effect.Carrier
import Data.Coerce
import Control.Monad.IO.Class
import GHC.Generics (Generic1)
newtype HttpC m a = HttpC { runHttpC :: m a }
deriving (Applicative, Functor, Monad, MonadIO)
deriving newtype (Applicative, Functor, Monad, MonadIO)
data HTTP (m :: * -> *) k
= Open String k
| Close k
| Post String (String -> k)
| HGet (String -> k)
deriving Functor
instance Effect HTTP where
handle state handler (Open s k) = Open s (handler . (<$ state) $ k)
handle state handler (Close k) = Close (handler . (<$ state) $ k)
handle state handler (Post s k) = Post s (handler . (<$ state) . k)
handle state handler (HGet k) = HGet (handler . (<$ state) . k)
instance HFunctor HTTP where
hmap _ = coerce
= Open String (m k)
| Close (m k)
| Post String (String -> m k)
| HGet (String -> m k)
deriving stock (Functor, Generic1)
deriving anyclass (HFunctor, Effect)
open' :: String -> HttpM ()
open' s = send (Open s (pure ()))
@ -46,7 +38,7 @@ instance (Effect sig, Carrier sig m) => Carrier (HTTP :+: sig) (HttpC m) where
Open _ k -> k
Close k -> k
Post s k -> k ("posted " <> s)
HGet k -> k "lmao"
HGet k -> k "lmao"
eff (R other) = HttpC (eff (handleCoercible other))
runHttp :: HttpM a -> IO a

View File

@ -1,10 +1,10 @@
{-# LANGUAGE DataKinds, TemplateHaskell, KindSignatures, GADTs, FlexibleContexts, TypeOperators, LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables, DataKinds, TemplateHaskell, KindSignatures, GADTs, FlexibleContexts, TypeOperators, LambdaCase #-}
module Poly.HTTP where
import Polysemy
type HttpM = Sem '[Http, Lift IO]
type HttpM = Sem '[Http, Final IO]
data Http (m :: * -> *) a where
HOpen :: String -> Http m ()
@ -34,4 +34,4 @@ runHttp' = interpret $ \case
HGet -> pure "contents"
runHttp :: HttpM a -> IO a
runHttp = runM . runHttp'
runHttp = runFinal . runHttp'