Skip to content

Instantly share code, notes, and snippets.

@googleson78
Last active August 5, 2021 16:19
Show Gist options
  • Save googleson78/81ae0e06858694f3e24ea45a642b5d91 to your computer and use it in GitHub Desktop.
Save googleson78/81ae0e06858694f3e24ea45a642b5d91 to your computer and use it in GitHub Desktop.
trying to do applicativedo with qualifieddo
{-# 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