Copyright | (c) Edward Kmett and Dan Doel 2013-2014 |
---|---|
License | BSD3 |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
- data Head = Head {
- _headDigest :: ByteString
- _hash :: !Int
- _headClass :: !Global
- _headBoundKinds :: !Int
- _headBoundTypes :: [Kind Int]
- _headKindArgs :: [Kind Int]
- _headTypeArgs :: [Type Int Int]
- class HasHead t where
- head_ :: Lens' t Head
- headClass :: Lens' t Global
- headBoundKinds :: Lens' t Int
- headBoundTypes :: Lens' t [Kind Int]
- headKindArgs :: Lens' t [Kind Int]
- headTypeArgs :: Lens' t [Type Int Int]
- mkHead :: Global -> Int -> [Kind Int] -> [Kind Int] -> [Type Int Int] -> Head
Documentation
In the instance declaration:
instance Foo a => Bar Int [a] where ...
The portion Bar Int [a]
is the head of the instance. All instances
must have a unique head; type class dispatch does not take the context
of the instance into account. Thus, instances are uniquely identified by
their heads, and we use them for that purpose among others.
The Head type records all the information necessary for this unique identification, plus a hash for fast equality checks.
The above instance head would be represented as something like:
Head ... Bar 0 [star] [] [int, list (B 0)]
Head | |
|
headClass :: Lens' t Global Source
headBoundKinds :: Lens' t Int Source
headBoundTypes :: Lens' t [Kind Int] Source
headKindArgs :: Lens' t [Kind Int] Source
headTypeArgs :: Lens' t [Type Int Int] Source