FS

Blog Archive

Monday, July 23, 2007

ICFP '07 Post-Mortem: I

This is the first of a few posts outlining Creighton and myself's effort towards this years IFCP programming competition. We didn't get too far, but I've learned a lot (more) about Haskell along the way.

I plan on doing one post per module, and this first post defines the Maybe monad transformer, which isn't in GHC (yet?) but made our code look much neater.


Check it out!

=======================
Maybe.lhs


> {-# OPTIONS -fallow-undecidable-instances -fglasgow-exts #-}

> module Maybe where


Almost all of this is taken from the Haskell Wiki


> import Control.Monad
> import Control.Monad.Trans
> import Control.Monad.State

> newtype MaybeT m a = MaybeT {runMaybeT :: m (Maybe a)}

> instance Functor m => Functor (MaybeT m) where
> fmap f x = MaybeT $ fmap (fmap f) $ runMaybeT x

> instance Monad m => Monad (MaybeT m) where
> return = MaybeT . return . return
> x >>= f = MaybeT $ runMaybeT x >>= maybe (return Nothing) (runMaybeT . f)
> fail _ = MaybeT $ return Nothing

> instance Monad m => MonadPlus (MaybeT m) where
> mzero = MaybeT $ return mzero
> mplus x y = MaybeT $ liftM2 mplus (runMaybeT x) (runMaybeT y)

> instance MonadTrans MaybeT where
> lift = MaybeT . liftM return


Here are my contributions, which I shoudl proabbly give back to the wiki: the MonadIO instance and the MonadState instance. You'd think these would generalize to any instance of MonadTrans, seeing as I only use lift. I haven't tried it yet.


> instance MonadIO m => MonadIO (MaybeT m) where
> liftIO = lift . liftIO


My Haskell-fu isn't good enough to make the instance of MonadState work without -fallow-undecidable-instances. If anyone knows why, let me know.


> instance (MonadState s m) => MonadState s (MaybeT m) where
> get = lift get
> put = lift . put

29 comments:

yinghong said...

rappelz rupees of Rappelz Online Game has more functions and this Rappelz Game is a very good free game. This rappelz gold of score could go down A LOT if they choose to mess up the classes even more. I would have rated it much cheap rappelz rupees better when it was epic3. If yes, then the first step to buy rupees when you play Rappelz is for you. Play rappelz and feel the power and might of rappelz money. See you in game!
rohan crone has many ways for us to use. When you start the Rohan Online game, your character will be level 1. I remembered that when I started playing this Rohan game with some little cheap rohan money. My friends all told me that the best way to spend rohan online gold is a good way. But I could not like spending my own rohan online crone. If you do not like upgrading level step by step, you can cost rohan gold to help your character to reach level high.

Anonymous said...

You know ,I have some priston tale Gold, and my friend also has some
priston tale Money, do you kouw they have the same meaning,I just want to
buy priston tale Gold, because there are many
cheap priston tale Gold.
You know ,I have some shadow of legend Gold, and my friend also has some
sol gold, do you kouw they have the same meaning,Both of them can be called
shadow of legend money,I just want to
buy shadow of legend Gold, because there are many
cheap shadow of legend Gold.

Anonymous said...

We have holic gold. He gave me some holic money, he said that I could buy holic online gold, but I did not have money, then I played it all my spare time. From then on, I got some cheap holic gold. We also sell holic online money

Anonymous said...

The twelve sky Gold should be a timely evolution of the world. Please step up efforts to investigate all types of 12sky gold can be set up in the game. 12Sky Silver Coins to add more rudimentary fashion. The twelvesky Gold can help you combat equipment of the production. Use the 12 sky gold may change the door to door battle for offensive.
I know that most players use aion kina to get a shiny cool weapon like other players in game. To enhance something, you need enhance stones with aion online kina. The process of enhancing is simple if you have aion gold. You can buy aion kina after clicking enhance. The equipment will be enhanced to the next level if you have more cheap aion kina.

rhtehe said...

Do you know the eve isk, in the game you need the eve online isk. it can help you increase your level. My friends always asked me how to
buy eve online isk, and I do not know he spend how much money to
buy isk, when I see him in order to play the game and search which the place can buy the
cheap eve isk. I am happy with him.
Do you know the dofus kamas , in the game you need the kamas. it can help you increase your level. My friends always asked me how to buy dofus kamas, and I do not know he spend how much money to buy the
dofus gold, when I see him in order to play the game and search which the place can buy the
cheap kamas. I am happy with him.

fangyan said...

Making World of Kung fu Gold is the old question : Honestly there is no fast way to make lots of WoKf gold . Sadly enough a lot of the people that all of a sudden come to with millions of buy World of Kung fu Gold almost overnight probably duped . Although there are a lot of ways to make lots of cheap World of Kung fu Gold here I will tell you all of the ways that I know and what I do to buy World of Kung fu money.


As a new player , you may need some game guides or information to enhance yourself.
wow gold is one of the hardest theme for every class at the beginning . You must have a good way to manage your World of Warcraft Gold.If yor are a lucky guy ,you can earn so many warcraft gold by yourself . But if you are a not , I just find a nice way to buy wow gold. If you need , you can buy cheap wow gold at our website . Go to the related page and check the detailed information .

Anonymous said...

As a new player , you may need some game guides or information to enhance yourself.
aoc gold is one of the hardest theme for every class at the beginning . You must have a good way to manage your conan gold.If yor are a lucky guy ,you can earn so many age of conan gold by yourself . But if you are a not , I just find a nice way to get cheap aoc gold. If you need , you can buy aoc money at our website . Go to the related page and check the detailed information . Once you have any question , you can connect our customer service at any time .

Making requiem gold is the old question : Honestly there is no fast way to make lots of requiem lant . Sadly enough a lot of the people that all of a sudden come to with millions of requiem money almost overnight probably duped . Although there are a lot of ways to make lots of cheap requiem lant here I will tell you all of the ways that I know and what I do to buyrequiem online gold.

Gold Guide for World of Warcraft said...

good post :)

Anonymous said...

Do you want to know the magic of online games, and here you can get more angels gold. Do you want to have a try? Come on and angels online gold can make you happy. You can change a lot buy angels gold for play games. And you can use the cheap angels online gold do what you want to do in the online game.

Anonymous said...

What do you know Sho Online Mun. And do you want to know? You can get Sho Mun here. And welcome to our website, here you can play games, and you will get Sho Online gold to play game. I know Sho gold, and it is very interesting. Do you want a try, come and view our website, and you will learn how to buy Sho Online gold. Come and join with us. We are waiting for your coming.

Anonymous said...

Do you know that the wow gold? The players often forget to eat meal when they play the online games. In the game many players need the World of Warcraft Gold to up their levels. so they often search where can warcraft gold, I think our website maybe is your best choice. Many friends told me that in here can get buy wow gold, and here you can also relax yourself. so i hope more and more players come here to buy the cheap wow gold.

Anonymous said...

Do you know Asda Story gold? I like it. My brother often goes to the internet bar to buy Asda Story money and play it. After school, He likes playing games using these buy Asda Story Gold with his friend. One day, he give me manycheap Asda Story gold and play the game with me.

Anonymous said...

Do you know Asda Story gold? I like it. My brother often go to the internet bar to buy Asda Story money and play it. After school, He likes playing games using these buy Asda Story Gold with his friend. One day, he give me manycheap Asda Story gold and play the game with me.

Anonymous said...

Do you know Asda Story gold? I like it. My brother often goes to the internet bar to buy Asda Story money and play it. After school, He likes playing games using these buy Asda Story Gold with his friend. I do not like to play it. Because I think that it not only costs much money but also spend much time. One day, he give me manycheap Asda Story gold and play the game with me.

Anonymous said...

Remembered the first time I played the game and bought wonderland Gold , it is about two years. Since the first day I bought wonderland online Gold , we should know that the day will come sooner or later. And I will not leave my wonderland money . My friends forever, even though I will leave you one day, I will remember you forever. At that time, I was a naive; I must used money to buy wonderland Gold , as that I would not depend on myself. But I was not regret to buy cheap wonderland online Gold . It is just a way bring me to the success.

Anonymous said...

To buy rappelz rupees , it is not the aim of the rappelz. It is the game which brings a lot of happiness to me. We buy the rappelz gold together. The beautiful story, we can not be forgotten, buy rupees . You will not regret to have rappelz money . So I will continue to have cheap rappelz rupees , it is a beautiful fairy tale, it looks like my life.

Anonymous said...

runescape gold of RS Online Game, we have made several changes to Fun Orb. If you wish to buy runescape to explore other spell books, you should subscribe as a Fun Orb member. Shattered Plans - a galaxy-spanning strategy epic that use rs gold to allow up to six players to battle for supremacy. We only plan to pay cheap rs gold when we feel you will appreciate the updates. And we certainly feel that these changes and some runescape money are worth telling you about.

Anonymous said...

It is a very nice game silkroad gold, I like sro gold. You can play it silkroad online gold, you can buy the cheap silk road gold. You smart and buy cheap silkroad gold.

Anonymous said...

Do you know seal cegel? I like it.
My brother often go to the internet bar to buy sealonline cegel and play it.
After school, He likes playing games using these seal online cegel with his friends.
I do not like to play it. Because I think that it not only costs much money but also spend much time. One day, he give me many cheap seal cegeland play the game with me.
I came to the bar following him and found buy seal online cegelwas so cheap. After that, I also go to play game with him.

Anonymous said...

Do you know latale online gold? I like it. My brother often go to the internet bar to buy latale gold and play it. After school, He likes playing games using these latale money with his friends. I do not like to play it. Because I think that it not only costs much money but also spend much time. One day, he give me many buy latale online gold and play the game with me. I came to the bar following him and found cheap latale gold was so cheap. After that, I also go to play game with him.

lanzi said...

I can get Solstice Kron cheaply.
Yesterday i bought Solstice Online Kronfor my brother.
i hope him like it. i will give Solstice Gold to him
as birthday present. i like the Solstice Online money very much.
I usually buy cheap Solstice Kron and keep it in my store.

I can get Solstice Kron cheaply.
Yesterday i bought Solstice Online Kronfor my brother.
i hope him like it. i will give Solstice Gold to him
as birthday present. i like the Solstice Online money very much.
I usually buy cheap Solstice Kron and keep it in my store.

Anonymous said...

Have you heared about 9Dragons which you need use 9Dragons gold to play, and you can also borrow 9 Dragons gold from other players? But you can buy 9 Dragons gold, or you will lose the choice if you do not have cheap 9Dragons gold. If you get 9Dragons money, you can

Anonymous said...

Have you heared about a game which you need use Anarchy credits to play, and you can also borrow Anarchy Online credits from other players? But you can buy AO credits, or you will lose the choice if you do not have Anarchy online gold. If you get Anarchy gold, you can continue this game.

Anonymous said...

Have you heared about a game which you need use Atlantica online Gold to play, and you can also borrow Atlantica Gold from other players? But you can buy Atlantica online Gold, or you will lose the choice if you do not have cheap Atlantica online Gold. If you get Atlantica online money, you can continue this game.

Anonymous said...

Making knight gold is the old question : Honestly there is no fast way to make lots of knight noah . Sadly enough a lot of the people that all of a sudden come to with millions of knight online gold almost overnight probably duped . Although there are a lot of ways to make lots of knight online noah here I will tell you all of the ways that I know and what I do to buycheap knight gold.

春香 said...

As a new player , you may need some game guides or information to enhance yourself.
requiem gold is one of the hardest theme for every class at the beginning . You must have a good way to manage your requiem lant.If yor are a lucky guy ,you can earn so many requiem money by yourself . But if you are a not , I just find a nice way to get cheap requiem lant. If you need , you can buy requiem online gold at our website . Go to the related page and check the detailed information . Once you have any question , you can connect our customer service at any time .

Anonymous said...

One very common item bought with cheap SOF gold at the store would be a pet. The Gameim.com is offering you with Scions Of Fate money and all kinds of cheap game gold. Scions Of Fate gold is sometimes need to pay for in this Scions of Fate game. For example in this game, we have to buy sof gold to exchange premium in order to protect our character. The only part of this game will require you to pay SOF gold but they are optional for you to choose in the premium store.
Frogster continues to throw the Runes of Magic Gold all the game-play they can possibly find into Runes of Magic. Rom Gold which I have spent much more in this game it is necessary. Once the race card is full the race begins, with players avoiding to buy Rom Gold and magical traps. It just amazes me how cheap Runes of Magic Gold and stuff Frogster is tossing into Runes of Magic. Players can help themselves and hinder their foes by picking up Runes of Magic money.

xw said...

The twelve sky Gold should be a timely evolution of the world. Please step up efforts to investigate all types of 12sky gold can be set up in the game. 12Sky Silver Coins to add more rudimentary fashion. The twelvesky Gold can help you combat equipment of the production. Use the 12 sky gold may change the door to door battle for offensive and defensive resident.

Anonymous said...

The 12sky2 Gold should be a timely evolution of the world. Please step up efforts to investigate all types of twelve sky2 Gold can be set up in the game. twelvesky2 Gold to add more rudimentary fashion and to do some changes to the players. The buy 12sky2 Gold can help you combat equipment of the production. Use the cheap twelve sky2 Gold may change the door to door battle for offensive and defensive resident.

Listening:

Watching:

  • House
  • Ride Back