Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Reference = Reference' Text Hash
- data Reference' t h where
- ReferenceBuiltin t
- ReferenceDerived (Id' h)
- pattern Builtin :: t -> Reference' t h
- pattern DerivedId :: Id' h -> Reference' t h
- pattern Derived :: h -> Pos -> Reference' t h
- _DerivedId :: Prism' Reference Id
- type Id = Id' Hash
- data Id' h = Id h Pos
- type Pos = Word64
- type CycleSize = Word64
- type Size = CycleSize
- type TermReference = Reference
- type TermReferenceId = Id
- type TypeReference = Reference
- type TypeReferenceId = Id
- derivedBase32Hex :: Text -> Pos -> Maybe Reference
- component :: Hash -> [k] -> [(k, Id)]
- components :: [(Hash, [k])] -> [(k, Id)]
- groupByComponent :: [(k, Reference)] -> [[(k, Reference)]]
- componentFor :: Hash -> [a] -> [(Id, a)]
- componentFromLength :: Hash -> CycleSize -> Set Id
- unsafeFromText :: Text -> Reference
- isPrefixOf :: ShortHash -> Reference -> Bool
- fromText :: Text -> Either String Reference
- readSuffix :: Text -> Either String Pos
- showShort :: Int -> Reference -> Text
- showSuffix :: Pos -> Text
- toHash :: Reference -> Maybe Hash
- toId :: Reference -> Maybe Id
- fromId :: Id -> Reference
- toText :: Reference -> Text
- idToText :: Id -> Text
- unsafeId :: Reference -> Id
- toShortHash :: Reference -> ShortHash
- idToHash :: Id -> Hash
- idToShortHash :: Id -> ShortHash
- isBuiltin :: Reference -> Bool
Documentation
type Reference = Reference' Text Hash #
This is the canonical representation of Reference
data Reference' t h #
Either a builtin or a user defined (hashed) top-level declaration. Used for both terms and types.
pattern Builtin :: t -> Reference' t h | |
pattern DerivedId :: Id' h -> Reference' t h | |
pattern Derived :: h -> Pos -> Reference' t h |
Instances
Pos
is a position into a cycle, as cycles are hashed together.
Instances
Foldable Id' | |
Defined in U.Codebase.Reference fold :: Monoid m => Id' m -> m # foldMap :: Monoid m => (a -> m) -> Id' a -> m # foldMap' :: Monoid m => (a -> m) -> Id' a -> m # foldr :: (a -> b -> b) -> b -> Id' a -> b # foldr' :: (a -> b -> b) -> b -> Id' a -> b # foldl :: (b -> a -> b) -> b -> Id' a -> b # foldl' :: (b -> a -> b) -> b -> Id' a -> b # foldr1 :: (a -> a -> a) -> Id' a -> a # foldl1 :: (a -> a -> a) -> Id' a -> a # elem :: Eq a => a -> Id' a -> Bool # maximum :: Ord a => Id' a -> a # | |
Traversable Id' | |
Functor Id' | |
Show h => Show (Id' h) | |
Eq h => Eq (Id' h) | |
Ord h => Ord (Id' h) | |
type TermReference = Reference #
A term reference.
type TermReferenceId = Id #
A term reference id.
type TypeReference = Reference #
A type declaration reference.
type TypeReferenceId = Id #
A type declaration reference id.
components :: [(Hash, [k])] -> [(k, Id)] Source #
groupByComponent :: [(k, Reference)] -> [[(k, Reference)]] Source #
componentFor :: Hash -> [a] -> [(Id, a)] Source #
unsafeFromText :: Text -> Reference Source #
fromText :: Text -> Either String Reference Source #
todo: take a (Reference -> CycleSize) so that readSuffix
doesn't have to parse the size from the text.
examples:
builtins don’t have cycles >>> fromText "##Text.take" Right ##Text.take
derived, no cycle >>> fromText "#dqp2oi4iderlrgp2h11sgkff6drk92omo4c84dncfhg9o0jn21cli4lhga72vlchmrb2jk0b3bdc2gie1l06sqdli8ego4q0akm3au8" Right #dqp2o
derived, part of cycle >>> fromText "#dqp2oi4iderlrgp2h11sgkff6drk92omo4c84dncfhg9o0jn21cli4lhga72vlchmrb2jk0b3bdc2gie1l06sqdli8ego4q0akm3au8.12345" Right #dqp2o.12345
Errors with Left
on invalid hashes
>>> fromText "#invalid_hash.12345"
Left "Invalid hash: "invalid_hash""
showSuffix :: Pos -> Text Source #
toShortHash :: Reference -> ShortHash #
idToShortHash :: Id -> ShortHash #