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
Helps with testability, composability, etc. I'm using fused-effects in another project, our current major effects would look like this:
dataEphemerisData (m::Type->Type) kwhereGetPlanetPosition::Planet->JulianTime->EphemerisDatam (EitherStringEclipticPosition)
GetHouseCusps::HouseSystem->JulianTime->GeographicPosition->EphemerisDatamCuspsCalculationGetObliquity::JulianTime->EphemerisDatam (EitherStringObliquityInformation )
getPlanetPosition::HasEphemerisDatasigm=>Planet->JulianTime->m (EitherStringEclipticPosition)
getPlanetPosition p t = send $GetPlanetPosition p t
getHouseCusps::HasEphemerisDatasigm=>HouseSystem->JulianTime->GeographicPosition->mCuspsCalculation
getHouseCusps hs t p = send $GetHouseCusps hs t p
getObliquity::HasEphemerisDatasigm=>JulianTime->m (EitherStringObliquityInformation)
getObliquity = send .GetObliquitydataTimeZoneData (m::Type->Type) kwhereTimeAtPointToUTC::Double->Double->LocalTime->TimeZoneDatamUTCTime{- ORMOLU_DISABLE -}timeAtPointToUTC::HasTimeZoneDatasigm=>Double->Double->LocalTime->mUTCTime
timeAtPointToUTC lt lg localTime = send $TimeAtPointToUTC lt lg localTime
newtypeEphemerisDataIOCma=EphemerisDataIOC{runEphemerisDataIO::ma}deriving (Applicative, Functor, Monad, MonadIO, MonadFail)
instance (MonadIOm, Algebrasigm) =>Algebra (EphemerisData:+:sig) (EphemerisDataIOCm) where
alg hdl sig ctx =case sig ofL (GetPlanetPosition p t) -> (<$ ctx) <$> liftIO (calculateEclipticPosition t p)
L (GetHouseCusps hs t p) -> (<$ ctx) <$> liftIO (calculateCusps hs t p)
L (GetObliquity t) -> (<$ ctx) <$> liftIO (calculateObliquity t)
R other ->EphemerisDataIOC (alg (runEphemerisDataIO . hdl) other ctx)
instance (MonadIOm, Algebrasigm)
=>Algebra (TimeZoneData:+:sig) (TimeZoneDataIOCm) where
alg hdl sig ctx =TimeZoneDataIOC$case sig ofL (TimeAtPointToUTC lt lg localTime) ->do
db <- ask
(<$ ctx) <$> liftIO (TZD.timeAtPointToUTC db lt lg localTime)
R other -> alg (runTimeZoneDataIO . hdl) (R other) ctx
newtypeTimeZoneDataIOCma=TimeZoneDataIOC{runTimeZoneDataIO::ReaderCTZD.TimeZoneDatabasema}deriving (Applicative, Functor, Monad, MonadIO, MonadFail)
runTimeZoneDataWithDB::TZD.TimeZoneDatabase->TimeZoneDataIOCma->ma
runTimeZoneDataWithDB db = runReader db . runTimeZoneDataIO
Note that the timezone runner only knows about the timezone database pointer in the TimeZoneDataIOC carrier, actual usage of the effect is none the wiser. Here's some example usage:
Note that horoscope now doesn't care about the timezone database or about opening the ephemeris path -- all of that happens when actually running in an effectful context (in this case, IO.)
The Servant story is a bit more complicated, but feasible, too.
The text was updated successfully, but these errors were encountered:
Helps with testability, composability, etc. I'm using
fused-effects
in another project, our current major effects would look like this:Note that the timezone runner only knows about the timezone database pointer in the
TimeZoneDataIOC
carrier, actual usage of the effect is none the wiser. Here's some example usage:Note that
horoscope
now doesn't care about the timezone database or about opening the ephemeris path -- all of that happens when actually running in an effectful context (in this case, IO.)The Servant story is a bit more complicated, but feasible, too.
The text was updated successfully, but these errors were encountered: