Skip to content

Commit

Permalink
Switch back to simple IP class.
Browse files Browse the repository at this point in the history
  • Loading branch information
yav committed Jun 10, 2012
1 parent c1177ef commit c6ff62c
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions GHC/IP.hs
Expand Up @@ -3,27 +3,12 @@
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -XNoImplicitPrelude #-}
module GHC.IP (IP, IPName(..), ipUse) where
module GHC.IP (IP(..)) where

import GHC.TypeLits

-- | A singleton type used to name implicit parameters.
data IPName (name :: Symbol) = IPName

-- | A type used to give values to implicit parameters.
-- The name is a phantom parameter because it needs no run-time representation.
newtype IPValue (name :: Symbol) a = IPValue a


-- | The syntax @?x@ is desuagred into @ipUse (IPName :: "x")@
ipUse :: IP x a => IPName x -> a
ipUse x = case val x of
IPValue a -> a
where val :: IP x a => IPName x -> IPValue x a
val _ = ip

-- | The syntax @?x :: a@ is desugared into @IP "x" a@
class IP x a | x -> a where
ip :: IPValue x a
class IP (x :: Symbol) a | x -> a where
ip :: a


0 comments on commit c6ff62c

Please sign in to comment.