Quick actions

cmd+k|ctrl+k

Navigation

Languages

MTL Orphan Instances

Snippet info

Language

Haskell

Visibility

public

Author

homam

Created

2018-03-07T08:16:37Z

Updated

2018-03-07T08:16:37Z

{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Main where

import          Counter
import          Weather

newtype MyAppM m a = MyAppM { unMyAppM :: MockCounter (MockWeather m) a }
  deriving (Functor, Applicative, Monad, CounterT, WeatherT)


instance Monad m => WeatherT (MockCounter (MockWeather m))

runMyAppM :: Int -> MyAppM m a -> m (a, Int)
runMyAppM i = runMockWeather . (`runMockCounter` i) . unMyAppM


myApp :: (Monad m, CounterT m , WeatherT m) => m String
myApp = do
  _ <- increment
  (WeatherData weather) <- byCity "Amsterdam"
  return weather

main :: IO ()
main = runMyAppM 12 myApp >>= print
INFO