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

  • Home
  • SEARCH
  • 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 8287857
In Process

The Archive Base Latest Questions

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

full code https://github.com/gertcuykens/haskell-design How can i lift Maybe from Maybe Text type application ::

  • 0

full code https://github.com/gertcuykens/haskell-design

How can i lift Maybe from Maybe Text type

application :: MVar ServerState -> WS.Request -> WS.WebSockets WS.Hybi10 ()
application state rq = do
    WS.acceptRequest rq
    WS.getVersion >>= liftIO . putStrLn . ("Client version: " ++)
    sink <- WS.getSink
    msg <- WS.receiveData
    clients <- liftIO $ readMVar state
    url <- liftIO fbUrl

    let prefix = "Facebook code"
    let code = T.drop (T.length prefix) msg

    let a = ("code",T.unpack code)
    e <- liftIO $ fbEmail $ (\(x,y) -> (C.pack x, C.pack y)) a

    let client = (e, sink) --ERROR

    case msg of
        _   | not (prefix `T.isPrefixOf` msg) -> do
                WS.sendTextData ("Facebook login " `mappend` url :: Text)
            | any ($ fst client)
                [T.null, T.any isPunctuation, T.any isSpace] ->
                    WS.sendTextData ("Facbook code invalid" :: Text)
            | clientExists client clients ->
                WS.sendTextData ("User already exists" :: Text)
            | otherwise -> do
                liftIO $ modifyMVar_ state $ \s -> do
                    let s' = addClient client s
                    WS.sendSink sink $ WS.textData $
                        "Welcome! Users: " `mappend`
                        T.intercalate ", " (map fst s)
                    broadcast (fst client `mappend` " joined") s'
                    return s'
                talk state client

    Couldn't match expected type `Maybe Text' with actual type `Text'
    Expected type: Maybe Text -> Bool
      Actual type: Text -> Bool
    In the expression: T.null
    In the second argument of `any', namely
      `[T.null, T.any isPunctuation, T.any isSpace]'
  • 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-08T12:09:28+00:00Added an answer on June 8, 2026 at 12:09 pm

    Your fbEmail function returns a Maybe Text. If you expect it to always be a Just, you could use a pattern on the left hand side of the variable binding to get the Text from it:

    Just email <- liftIO . fbEmail $ both C.pack a
    

    With the following helper to improve readability:

    both :: (a -> b) -> (a, a) -> (b, b)
    both f (x, y) = (f x, f y)
    

    This ignores errors, however, so you ought to use one of the Data.Maybe functions such as fromMaybe or maybe. Alternatively, you could also use an explicit case expression:

    maybeEmail <- ...
    case maybeEmail of
      Just email -> ...  -- Do something with "email".
      Nothing ->    ...  -- Handle missing emails.
    

    If you don’t need to do different things in the caller based on whether fbEmail returned a Nothing or Just, you can (and should) move this logic into fbEmail itself.

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

Sidebar

Related Questions

Full code at https://gist.github.com/992562 . I am using HTML File API and drag/drop to
I have upload the video on facebook using following code Help From : https://github.com/zoul/facebook-ios-sdk/
UPDATE : The full site code is here - https://github.com/eWizardII/PeerInstruction I have the following
I'm drawing a puzzle in HTML5 Canvas. Full code so far is here: https://github.com/Integralist/HTML5-Image-Slider-Game
you can view full source code here dpaste.com/hold/167199 Error: delete() takes exactly 2 arguments
I'm trying to read the ticker symbol at https://mtgox.com/api/0/data/ticker.php from my C++ application. I
I am using https://github.com/thest1/LazyList for image caching. I have to diaplay image in full
I'm using this pretty handy JavaScript template library: https://github.com/blueimp/JavaScript-Templates . I can create elements
Does anyone has the code to a full working example of slartoolkit ( http://slartoolkit.codeplex.com/
Are there any packages that can take a directory full of source code (Objective-C

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.