This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Service.TypesSpec where | |
-------------------------------------------------------------------------------- | |
import Test.Hspec | |
import Test.QuickCheck | |
-------------------------------------------------------------------------------- | |
import Data.List (nub) | |
import Data.Text (Text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Monad.Reader | |
data AppContext = AppContext { a :: String, b :: Int } | |
newtype AppT a = AppT { runAppT :: ReaderT AppContext IO a } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Monad.Reader | |
-- a basic IO function | |
f :: IO String | |
f = return "string" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad.Writer | |
import Control.Monad.Except | |
import Data.Functor.Identity | |
f :: Monad m | |
=> (String -> String -> m String) | |
-> String | |
-> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE NoMonomorphismRestriction #-} | |
module Main where | |
import Control.Monad.IO.Class (MonadIO, liftIO) | |
import Crypto.JOSE (Error) | |
import Crypto.JOSE.JWK (JWK) | |
import Data.Aeson (FromJSON, ToJSON, decode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Monad.IO.Class (liftIO) | |
import Crypto.JOSE (Error) | |
import Crypto.JOSE.JWK (JWK) | |
import Data.Aeson (FromJSON, ToJSON, decode) | |
import Data.ByteString (ByteString) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.Monoid | |
data Pav a = Pav a | EmptyPav deriving (Show) | |
instance Semigroup Int where | |
a <> b = a + b | |
instance Monoid Int where | |
mappend a b = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Main where | |
import Control.Monad.IO.Class | |
import Control.Monad.Reader | |
newtype A a = A { runA :: IO a } deriving (Functor, Applicative, Monad, MonadIO) | |
newtype B a = B { runB :: ReaderT () IO a } deriving (Functor, Applicative, Monad, MonadIO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE EmptyDataDeriving #-} | |
data DbNames deriving (Eq, Ord, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
f :: Int -> String -> String | |
f n a = mconcat . take n . repeat $ a | |
g :: String -> String -> String | |
g a b = b <> " " <> a | |
z :: (String -> String) -> String | |
z f = f "world" |