Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,412
    • Issues 5,412
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 606
    • Merge requests 606
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #303
Closed
Open
Issue created Feb 09, 2005 by nobody@trac-nobody

Rebindable syntax doesn't work as advertised

--
-- According to section 7.3.5. Rebindable syntax in the
user's manual
-- this should work (unless I totally misunderstood it).
-- It doesn't.
--
-- Compile with -fno-implicit-prelude
--
--     Lennart
--

import Prelude hiding(Monad(..))

class B a where
    b :: a

instance B Bool where
    b = False

class M m where 
    return :: a -> m a
    (>>=)  :: (B a) => m a -> (a -> m b) -> m b
    (>>)   :: (B a) =>  m a -> m b -> m b
    fail   :: String -> m a
  
    p >> q  = p >>= \ _ -> q
    fail s  = error s
   
instance M Maybe where
    return x = Just x
    (>>=) = error "bind"

test :: Maybe Bool
test = do
    x <- return True
    return (x && x)

unJust (Just x) = x

main = print (unJust test)
Edited Mar 09, 2019 by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking