Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8279095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:13:26+00:00 2026-06-08T09:13:26+00:00

Reference haskell facebook example works perfect, but now I can’t figure out how to

  • 0

Reference haskell facebook example works perfect, but now I can’t figure out how to split it in a separate module so I can do something useful with it. Also I can’t figure out what type I need to put for fbEmail fbUrl and if I need to put OverloadedStrings in every module? Maybe my thinking process is wrong and its simple not possible to separate the import Network.HTTP.Conduit (withManager) from main?

login.hs

{-# LANGUAGE OverloadedStrings, NoMonomorphismRestriction #-}
module Login (
    fbUrl,
    fbEmail
) where

import qualified Facebook as FB
import Network.HTTP.Conduit (withManager)
import Data.Text
import Data.ByteString.Internal (ByteString)

app :: FB.Credentials
app = FB.Credentials "localhost" "249348058430770" "..."

url :: FB.RedirectUrl
url = "http://localhost/fb"

perms :: [FB.Permission]
perms = ["user_about_me", "email"]

fbUrl = FB.getUserAccessTokenStep1 url perms

fbEmail c = withManager $ \manager -> FB.runFacebookT app manager $ do
    t <- FB.getUserAccessTokenStep2 url [c]
    u <- FB.getUser "me" [] (Just t)
    return $ FB.userEmail u

main.hs

module Main (
  main
) where

import Login
import System.IO

main :: IO ()
main = do
    u <- fbUrl
    print u
    a <- readLn
    e <- fbEmail a
    print e

I get the following error

src/Main.hs:11:10:
Couldn't match expected type `IO t0'
            with actual type `fb-0.9.6:Facebook.Monad.FacebookT
                                fb-0.9.6:Facebook.Monad.Auth m0 Data.Text.Internal.Text'
In a stmt of a 'do' block: u <- fbUrl
In the expression:
  do { u <- fbUrl;
       print u;
       a <- readLn;
       e <- fbEmail a;
       .... }
In an equation for `main':
    main
      = do { u <- fbUrl;
             print u;
             a <- readLn;
             .... }

CODE UPDATE 6: see answer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:13:27+00:00Added an answer on June 8, 2026 at 9:13 am

    To summarise what was going on in the comments the issue was, essentially, threefold. You tried to return a Maybe Text rather than a FacebookT ... (Maybe Text), due to missing a return, the lack of type signatures made the monomorphism restriction kick inm and finally you forgot to runFacebookT in main.

    EDIT: The fourth problem is that you’re giving fbEmail a too polymorphic type, the type checker complains that the type variable a actually has to be exactly (ByteString, ByteString). EDIT: Using a type variable here states that the function could be applied to anything, which isn’t the case, as getUserAccessTokenStep2 wants a list of pairs of ByteStrings (rather than just an arbitrary list).

    EDIT: The fifth issue is due to the requirement that FacebookT be taken over any monad is too weak (withManager requires it to be a bunch of more specific things, such as MonadIO). As you can see in the error it’s rather a long list of things, and you might be better off just removing the type signature from fbEmail and enable the NoMonomorphismRestriction extension (just add it to the list of extensions where you have OverloadedStrings.

    Note that generally you should have explicit type declarations, but I’m not too familiar with the conduits package (I’m more of a pipes person :P), and I don’t know if there is some constraint synonym trick there to make it less verbose.

    Unless these were just silly typos you might want to read up on monads and monad transformers in one of the many tutorials floating around (or check the haskell wiki).

    Also questions such as these might be considered a little too specific for stackoverflow (see the FAQ) and more appropriate to the haskell IRC channel (I’ll flag it once we’ve managed to got it running the way you want, but in future I suggest you try the IRC channel on FreeNode :)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's take a common example how a haskell function can be called from a
Is is possible to have reference to module in haskell? I have several modules,
Can anybody explain the difference in Haskell between the operators ($) and ($!) (dollar
I want to call haskell functions out of C++ and did use the tutorial
I searched on google, searched on google with site:haskell.org, and used hoogle. But I
Can I somehow use inline assembly in Haskell (similar to what GCC does for
Reference: http://www.facebook.com/note.php?note_id=389414033919 They said they build it in PHP and Javascript, which is great,
UPDATE SOLVED I updated to Haskell Platform 2011.2.0.1 and GHC 7.0.3 and now it
I've noticed that in functional languages such as Haskell and OCaml you can do
reference How can I disable the use of the Tab key to select the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.