Last active
August 5, 2021 16:19
-
-
Save googleson78/81ae0e06858694f3e24ea45a642b5d91 to your computer and use it in GitHub Desktop.
trying to do applicativedo with qualifieddo
This file contains hidden or 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 TypeFamilies #-} | |
module Ado where | |
(>>=) :: Int ~ Char => f a -> (a -> f b) -> f b | |
(>>=) = undefined | |
(<*>) :: Applicative f => f (a -> b) -> f a -> f b | |
(<*>) = (Prelude.<*>) | |
pure :: Applicative f => a -> f a | |
pure = Prelude.pure | |
return :: Applicative f => a -> f a | |
return = Prelude.pure | |
fmap :: Functor f => (a -> b) -> f a -> f b | |
fmap = Prelude.fmap | |
join :: Int ~ Char => m (m a) -> m a | |
join = undefined | |
---- | |
{-# LANGUAGE QualifiedDo #-} | |
{-# LANGUAGE ApplicativeDo #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | |
module Adotry where | |
import qualified Ado as A | |
newtype List a = List [a] | |
deriving newtype (Show, Functor, Applicative) | |
xs :: List Int | |
xs = A.do | |
x <- List [1,2,3] | |
A.pure $ x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment