module Unison.Builtin
  ( codeLookup,
    constructorType,
    names,
    builtinDataDecls,
    builtinEffectDecls,
    builtinConstructorType,
    builtinTypeDependents,
    builtinTypeDependentsOfComponent,
    builtinTypes,
    builtinTermsByType,
    builtinTermsByTypeMention,
    intrinsicTermReferences,
    intrinsicTypeReferences,
    isBuiltinType,
    typeOf,
    typeLookup,
    termRefTypes,
    termRefTypeReferences,
  )
where

import Data.Map qualified as Map
import Data.Set qualified as Set
import Data.Text qualified as Text
import Text.Regex.TDFA qualified as RE
import Unison.Builtin.Decls qualified as DD
import Unison.Builtin.Terms qualified as TD
import Unison.Codebase.CodeLookup (CodeLookup (..))
import Unison.ConstructorReference (GConstructorReference (..))
import Unison.ConstructorType qualified as CT
import Unison.DataDeclaration qualified as DD
import Unison.Hash (Hash)
import Unison.Hashing.V2.Convert qualified as H
import Unison.Name (Name)
import Unison.Names (Names (Names))
import Unison.Parser.Ann (Ann (..))
import Unison.Prelude
import Unison.Reference qualified as R
import Unison.Referent qualified as Referent
import Unison.Symbol (Symbol)
import Unison.Syntax.Name qualified as Name (unsafeParseText, unsafeParseVar)
import Unison.Type qualified as Type
import Unison.Typechecker.TypeLookup qualified as TL
import Unison.Util.Relation qualified as Rel
import Unison.Var qualified as Var

type DataDeclaration = DD.DataDeclaration Symbol Ann

type EffectDeclaration = DD.EffectDeclaration Symbol Ann

type Type = Type.Type Symbol ()

names :: Names
names :: Names
names = Relation Name Referent -> Relation Name TermReference -> Names
Names Relation Name Referent
terms Relation Name TermReference
types
  where
    terms :: Relation Name Referent
terms =
      (TermReference -> Referent)
-> Relation Name TermReference -> Relation Name Referent
forall a b b'.
(Ord a, Ord b, Ord b') =>
(b -> b') -> Relation a b -> Relation a b'
Rel.mapRan TermReference -> Referent
Referent.Ref (Map Name TermReference -> Relation Name TermReference
forall a b. (Ord a, Ord b) => Map a b -> Relation a b
Rel.fromMap Map Name TermReference
termNameRefs)
        Relation Name Referent
-> Relation Name Referent -> Relation Name Referent
forall a. Semigroup a => a -> a -> a
<> [(Name, Referent)] -> Relation Name Referent
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList
          [ (Symbol -> Name
forall v. Var v => v -> Name
Name.unsafeParseVar Symbol
vc, ConstructorReference -> ConstructorType -> Referent
Referent.Con (TermReference -> Pos -> ConstructorReference
forall r. r -> Pos -> GConstructorReference r
ConstructorReference (Id -> TermReference
forall h t. Id' h -> Reference' t h
R.DerivedId Id
r) Pos
cid) ConstructorType
ct)
            | (ConstructorType
ct, (Symbol
_, (Id
r, DataDeclaration
decl))) <-
                ((ConstructorType
CT.Data,) ((Symbol, (Id, DataDeclaration))
 -> (ConstructorType, (Symbol, (Id, DataDeclaration))))
-> [(Symbol, (Id, DataDeclaration))]
-> [(ConstructorType, (Symbol, (Id, DataDeclaration)))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, (Id, DataDeclaration))]
builtinDataDecls)
                  [(ConstructorType, (Symbol, (Id, DataDeclaration)))]
-> [(ConstructorType, (Symbol, (Id, DataDeclaration)))]
-> [(ConstructorType, (Symbol, (Id, DataDeclaration)))]
forall a. Semigroup a => a -> a -> a
<> ((ConstructorType
CT.Effect,) ((Symbol, (Id, DataDeclaration))
 -> (ConstructorType, (Symbol, (Id, DataDeclaration))))
-> ((Symbol, (Id, EffectDeclaration Symbol Ann))
    -> (Symbol, (Id, DataDeclaration)))
-> (Symbol, (Id, EffectDeclaration Symbol Ann))
-> (ConstructorType, (Symbol, (Id, DataDeclaration)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((Id, EffectDeclaration Symbol Ann) -> (Id, DataDeclaration))
-> (Symbol, (Id, EffectDeclaration Symbol Ann))
-> (Symbol, (Id, DataDeclaration))
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (((Id, EffectDeclaration Symbol Ann) -> (Id, DataDeclaration))
 -> (Symbol, (Id, EffectDeclaration Symbol Ann))
 -> (Symbol, (Id, DataDeclaration)))
-> ((EffectDeclaration Symbol Ann -> DataDeclaration)
    -> (Id, EffectDeclaration Symbol Ann) -> (Id, DataDeclaration))
-> (EffectDeclaration Symbol Ann -> DataDeclaration)
-> (Symbol, (Id, EffectDeclaration Symbol Ann))
-> (Symbol, (Id, DataDeclaration))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EffectDeclaration Symbol Ann -> DataDeclaration)
-> (Id, EffectDeclaration Symbol Ann) -> (Id, DataDeclaration)
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second) EffectDeclaration Symbol Ann -> DataDeclaration
forall v a. EffectDeclaration v a -> DataDeclaration v a
DD.toDataDecl ((Symbol, (Id, EffectDeclaration Symbol Ann))
 -> (ConstructorType, (Symbol, (Id, DataDeclaration))))
-> [(Symbol, (Id, EffectDeclaration Symbol Ann))]
-> [(ConstructorType, (Symbol, (Id, DataDeclaration)))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, (Id, EffectDeclaration Symbol Ann))]
builtinEffectDecls),
              ((Ann
_, Symbol
vc, Type Symbol Ann
_), Pos
cid) <- DataDeclaration -> [(Ann, Symbol, Type Symbol Ann)]
forall v a. DataDeclaration v a -> [(a, v, Type v a)]
DD.constructors' DataDeclaration
decl [(Ann, Symbol, Type Symbol Ann)]
-> [Pos] -> [((Ann, Symbol, Type Symbol Ann), Pos)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [Pos
0 ..]
          ]
        Relation Name Referent
-> Relation Name Referent -> Relation Name Referent
forall a. Semigroup a => a -> a -> a
<> [(Name, Referent)] -> Relation Name Referent
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList
          [ (Symbol -> Name
forall v. Var v => v -> Name
Name.unsafeParseVar Symbol
v, TermReference -> Referent
Referent.Ref (Id -> TermReference
forall h t. Id' h -> Reference' t h
R.DerivedId Id
i))
            | (Symbol
v, Id
i) <- Map Symbol Id -> [(Symbol, Id)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Symbol Id
TD.builtinTermsRef
          ]
    types :: Relation Name TermReference
types =
      [(Name, TermReference)] -> Relation Name TermReference
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList [(Name, TermReference)]
builtinTypes
        Relation Name TermReference
-> Relation Name TermReference -> Relation Name TermReference
forall a. Semigroup a => a -> a -> a
<> [(Name, TermReference)] -> Relation Name TermReference
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList
          [ (Symbol -> Name
forall v. Var v => v -> Name
Name.unsafeParseVar Symbol
v, Id -> TermReference
forall h t. Id' h -> Reference' t h
R.DerivedId Id
r)
            | (Symbol
v, (Id
r, DataDeclaration
_)) <- [(Symbol, (Id, DataDeclaration))]
builtinDataDecls
          ]
        Relation Name TermReference
-> Relation Name TermReference -> Relation Name TermReference
forall a. Semigroup a => a -> a -> a
<> [(Name, TermReference)] -> Relation Name TermReference
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList
          [ (Symbol -> Name
forall v. Var v => v -> Name
Name.unsafeParseVar Symbol
v, Id -> TermReference
forall h t. Id' h -> Reference' t h
R.DerivedId Id
r)
            | (Symbol
v, (Id
r, EffectDeclaration Symbol Ann
_)) <- [(Symbol, (Id, EffectDeclaration Symbol Ann))]
builtinEffectDecls
          ]

-- note: this function is really for deciding whether `r` is a term or type,
-- but it can only answer correctly for Builtins.
isBuiltinType :: R.Reference -> Bool
isBuiltinType :: TermReference -> Bool
isBuiltinType TermReference
r = TermReference -> [TermReference] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem TermReference
r ([TermReference] -> Bool)
-> ([(Name, TermReference)] -> [TermReference])
-> [(Name, TermReference)]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Name, TermReference) -> TermReference)
-> [(Name, TermReference)] -> [TermReference]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Name, TermReference) -> TermReference
forall a b. (a, b) -> b
snd ([(Name, TermReference)] -> Bool)
-> [(Name, TermReference)] -> Bool
forall a b. (a -> b) -> a -> b
$ [(Name, TermReference)]
builtinTypes

typeLookup :: TL.TypeLookup Symbol Ann
typeLookup :: TypeLookup Symbol Ann
typeLookup =
  Map TermReference (Type Symbol Ann)
-> Map TermReference DataDeclaration
-> Map TermReference (EffectDeclaration Symbol Ann)
-> TypeLookup Symbol Ann
forall v a.
Map TermReference (Type v a)
-> Map TermReference (DataDeclaration v a)
-> Map TermReference (EffectDeclaration v a)
-> TypeLookup v a
TL.TypeLookup
    ((() -> Ann) -> Type -> Type Symbol Ann
forall a b. (a -> b) -> Term F Symbol a -> Term F Symbol b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Ann -> () -> Ann
forall a b. a -> b -> a
const Ann
Intrinsic) (Type -> Type Symbol Ann)
-> Map TermReference Type -> Map TermReference (Type Symbol Ann)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map TermReference Type
termRefTypes)
    ([(TermReference, DataDeclaration)]
-> Map TermReference DataDeclaration
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(TermReference, DataDeclaration)]
 -> Map TermReference DataDeclaration)
-> [(TermReference, DataDeclaration)]
-> Map TermReference DataDeclaration
forall a b. (a -> b) -> a -> b
$ ((Symbol, (Id, DataDeclaration))
 -> (TermReference, DataDeclaration))
-> [(Symbol, (Id, DataDeclaration))]
-> [(TermReference, DataDeclaration)]
forall a b. (a -> b) -> [a] -> [b]
map ((Id -> TermReference)
-> (Id, DataDeclaration) -> (TermReference, DataDeclaration)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Id -> TermReference
forall h t. Id' h -> Reference' t h
R.DerivedId ((Id, DataDeclaration) -> (TermReference, DataDeclaration))
-> ((Symbol, (Id, DataDeclaration)) -> (Id, DataDeclaration))
-> (Symbol, (Id, DataDeclaration))
-> (TermReference, DataDeclaration)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Symbol, (Id, DataDeclaration)) -> (Id, DataDeclaration)
forall a b. (a, b) -> b
snd) [(Symbol, (Id, DataDeclaration))]
builtinDataDecls)
    ([(TermReference, EffectDeclaration Symbol Ann)]
-> Map TermReference (EffectDeclaration Symbol Ann)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(TermReference, EffectDeclaration Symbol Ann)]
 -> Map TermReference (EffectDeclaration Symbol Ann))
-> [(TermReference, EffectDeclaration Symbol Ann)]
-> Map TermReference (EffectDeclaration Symbol Ann)
forall a b. (a -> b) -> a -> b
$ ((Symbol, (Id, EffectDeclaration Symbol Ann))
 -> (TermReference, EffectDeclaration Symbol Ann))
-> [(Symbol, (Id, EffectDeclaration Symbol Ann))]
-> [(TermReference, EffectDeclaration Symbol Ann)]
forall a b. (a -> b) -> [a] -> [b]
map ((Id -> TermReference)
-> (Id, EffectDeclaration Symbol Ann)
-> (TermReference, EffectDeclaration Symbol Ann)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Id -> TermReference
forall h t. Id' h -> Reference' t h
R.DerivedId ((Id, EffectDeclaration Symbol Ann)
 -> (TermReference, EffectDeclaration Symbol Ann))
-> ((Symbol, (Id, EffectDeclaration Symbol Ann))
    -> (Id, EffectDeclaration Symbol Ann))
-> (Symbol, (Id, EffectDeclaration Symbol Ann))
-> (TermReference, EffectDeclaration Symbol Ann)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Symbol, (Id, EffectDeclaration Symbol Ann))
-> (Id, EffectDeclaration Symbol Ann)
forall a b. (a, b) -> b
snd) [(Symbol, (Id, EffectDeclaration Symbol Ann))]
builtinEffectDecls)

constructorType :: R.Reference -> Maybe CT.ConstructorType
constructorType :: TermReference -> Maybe ConstructorType
constructorType TermReference
r =
  TypeLookup Symbol Ann -> TermReference -> Maybe ConstructorType
forall v a.
TypeLookup v a -> TermReference -> Maybe ConstructorType
TL.constructorType TypeLookup Symbol Ann
typeLookup TermReference
r
    Maybe ConstructorType
-> Maybe ConstructorType -> Maybe ConstructorType
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TermReference
-> Map TermReference ConstructorType -> Maybe ConstructorType
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup TermReference
r Map TermReference ConstructorType
builtinConstructorType

builtinDataDecls :: [(Symbol, (R.Id, DataDeclaration))]
builtinDataDecls :: [(Symbol, (Id, DataDeclaration))]
builtinDataDecls =
  [(Symbol
v, (Id
r, Ann
Intrinsic Ann -> DataDeclaration Symbol () -> DataDeclaration
forall a b.
a -> DataDeclaration Symbol b -> DataDeclaration Symbol a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ DataDeclaration Symbol ()
d)) | (Symbol
v, Id
r, DataDeclaration Symbol ()
d) <- [(Symbol, Id, DataDeclaration Symbol ())]
DD.builtinDataDecls]

builtinEffectDecls :: [(Symbol, (R.Id, EffectDeclaration))]
builtinEffectDecls :: [(Symbol, (Id, EffectDeclaration Symbol Ann))]
builtinEffectDecls = [(Symbol
v, (Id
r, Ann
Intrinsic Ann -> EffectDeclaration Symbol () -> EffectDeclaration Symbol Ann
forall a b.
a -> EffectDeclaration Symbol b -> EffectDeclaration Symbol a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ EffectDeclaration Symbol ()
d)) | (Symbol
v, Id
r, EffectDeclaration Symbol ()
d) <- [(Symbol, Id, EffectDeclaration Symbol ())]
DD.builtinEffectDecls]

codeLookup :: (Applicative m) => CodeLookup Symbol m Ann
codeLookup :: forall (m :: * -> *). Applicative m => CodeLookup Symbol m Ann
codeLookup = (Id -> m (Maybe (Term Symbol Ann)))
-> (Id -> m (Maybe (Decl Symbol Ann))) -> CodeLookup Symbol m Ann
forall v (m :: * -> *) a.
(Id -> m (Maybe (Term v a)))
-> (Id -> m (Maybe (Decl v a))) -> CodeLookup v m a
CodeLookup (m (Maybe (Term Symbol Ann)) -> Id -> m (Maybe (Term Symbol Ann))
forall a b. a -> b -> a
const (m (Maybe (Term Symbol Ann)) -> Id -> m (Maybe (Term Symbol Ann)))
-> m (Maybe (Term Symbol Ann)) -> Id -> m (Maybe (Term Symbol Ann))
forall a b. (a -> b) -> a -> b
$ Maybe (Term Symbol Ann) -> m (Maybe (Term Symbol Ann))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Term Symbol Ann)
forall a. Maybe a
Nothing) ((Id -> m (Maybe (Decl Symbol Ann))) -> CodeLookup Symbol m Ann)
-> (Id -> m (Maybe (Decl Symbol Ann))) -> CodeLookup Symbol m Ann
forall a b. (a -> b) -> a -> b
$ \Id
r ->
  Maybe (Decl Symbol Ann) -> m (Maybe (Decl Symbol Ann))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe (Decl Symbol Ann) -> m (Maybe (Decl Symbol Ann)))
-> Maybe (Decl Symbol Ann) -> m (Maybe (Decl Symbol Ann))
forall a b. (a -> b) -> a -> b
$
    Id -> [(Id, Decl Symbol Ann)] -> Maybe (Decl Symbol Ann)
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Id
r [(Id
r, DataDeclaration -> Decl Symbol Ann
forall a b. b -> Either a b
Right DataDeclaration
x) | (Id
r, DataDeclaration
x) <- (Symbol, (Id, DataDeclaration)) -> (Id, DataDeclaration)
forall a b. (a, b) -> b
snd ((Symbol, (Id, DataDeclaration)) -> (Id, DataDeclaration))
-> [(Symbol, (Id, DataDeclaration))] -> [(Id, DataDeclaration)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, (Id, DataDeclaration))]
builtinDataDecls]
      Maybe (Decl Symbol Ann)
-> Maybe (Decl Symbol Ann) -> Maybe (Decl Symbol Ann)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Id -> [(Id, Decl Symbol Ann)] -> Maybe (Decl Symbol Ann)
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Id
r [(Id
r, EffectDeclaration Symbol Ann -> Decl Symbol Ann
forall a b. a -> Either a b
Left EffectDeclaration Symbol Ann
x) | (Id
r, EffectDeclaration Symbol Ann
x) <- (Symbol, (Id, EffectDeclaration Symbol Ann))
-> (Id, EffectDeclaration Symbol Ann)
forall a b. (a, b) -> b
snd ((Symbol, (Id, EffectDeclaration Symbol Ann))
 -> (Id, EffectDeclaration Symbol Ann))
-> [(Symbol, (Id, EffectDeclaration Symbol Ann))]
-> [(Id, EffectDeclaration Symbol Ann)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, (Id, EffectDeclaration Symbol Ann))]
builtinEffectDecls]

-- Relation predicate: Domain depends on range.
builtinDependencies :: Rel.Relation R.Reference R.Reference
builtinDependencies :: Relation TermReference TermReference
builtinDependencies =
  Map TermReference (Set TermReference)
-> Relation TermReference TermReference
forall a b. (Ord a, Ord b) => Map a (Set b) -> Relation a b
Rel.fromMultimap (Type -> Set TermReference
forall v a. Ord v => Type v a -> Set TermReference
Type.dependencies (Type -> Set TermReference)
-> Map TermReference Type -> Map TermReference (Set TermReference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map TermReference Type
termRefTypes)

-- a relation whose domain is types and whose range is builtin terms with that type
builtinTermsByType :: Rel.Relation R.Reference Referent.Referent
builtinTermsByType :: Relation TermReference Referent
builtinTermsByType =
  [(TermReference, Referent)] -> Relation TermReference Referent
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList
    [ (Type -> TermReference
forall v a. Var v => Type v a -> TermReference
H.typeToReference Type
ty, TermReference -> Referent
Referent.Ref TermReference
r)
      | (TermReference
r, Type
ty) <- Map TermReference Type -> [(TermReference, Type)]
forall k a. Map k a -> [(k, a)]
Map.toList Map TermReference Type
termRefTypes
    ]

-- a relation whose domain is types and whose range is builtin terms that mention that type
-- example: Nat.+ mentions the type `Nat`
builtinTermsByTypeMention :: Rel.Relation R.Reference Referent.Referent
builtinTermsByTypeMention :: Relation TermReference Referent
builtinTermsByTypeMention =
  [(TermReference, Referent)] -> Relation TermReference Referent
forall a b. (Ord a, Ord b) => [(a, b)] -> Relation a b
Rel.fromList
    [ (TermReference
m, TermReference -> Referent
Referent.Ref TermReference
r) | (TermReference
r, Type
ty) <- Map TermReference Type -> [(TermReference, Type)]
forall k a. Map k a -> [(k, a)]
Map.toList Map TermReference Type
termRefTypes, TermReference
m <- Set TermReference -> [TermReference]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Set TermReference -> [TermReference])
-> Set TermReference -> [TermReference]
forall a b. (a -> b) -> a -> b
$ Type -> Set TermReference
forall v a. Var v => Type v a -> Set TermReference
H.typeToReferenceMentions Type
ty
    ]

-- The dependents of a builtin type is the set of builtin terms which
-- mention that type.
builtinTypeDependents :: R.Reference -> Set R.Reference
builtinTypeDependents :: TermReference -> Set TermReference
builtinTypeDependents TermReference
r = TermReference
-> Relation TermReference TermReference -> Set TermReference
forall b a. Ord b => b -> Relation a b -> Set a
Rel.lookupRan TermReference
r Relation TermReference TermReference
builtinDependencies

builtinTypeDependentsOfComponent :: Hash -> Set R.Reference
builtinTypeDependentsOfComponent :: Hash -> Set TermReference
builtinTypeDependentsOfComponent Hash
h0 = (TermReference -> Ordering)
-> Relation TermReference TermReference -> Set TermReference
forall a b.
(Ord a, Ord b) =>
(b -> Ordering) -> Relation a b -> Set a
Rel.searchRan TermReference -> Ordering
ord Relation TermReference TermReference
builtinDependencies
  where
    ord :: R.Reference -> Ordering
    ord :: TermReference -> Ordering
ord = \case
      R.Derived Hash
h Pos
_i -> Hash -> Hash -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Hash
h Hash
h0
      TermReference
r -> TermReference -> TermReference -> Ordering
forall a. Ord a => a -> a -> Ordering
compare TermReference
r TermReference
r0
    r0 :: TermReference
r0 = Hash -> Pos -> TermReference
forall h t. h -> Pos -> Reference' t h
R.Derived Hash
h0 Pos
0

-- WARNING:
-- As with the terms, we should avoid changing these references, even
-- if we decide to change their names.
builtinTypes :: [(Name, R.Reference)]
builtinTypes :: [(Name, TermReference)]
builtinTypes =
  Map Name TermReference -> [(Name, TermReference)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map Name TermReference -> [(Name, TermReference)])
-> (Map Text TermReference -> Map Name TermReference)
-> Map Text TermReference
-> [(Name, TermReference)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Name) -> Map Text TermReference -> Map Name TermReference
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys HasCallStack => Text -> Name
Text -> Name
Name.unsafeParseText (Map Text TermReference -> [(Name, TermReference)])
-> Map Text TermReference -> [(Name, TermReference)]
forall a b. (a -> b) -> a -> b
$
    (Map Text TermReference
 -> BuiltinTypeDSL -> Map Text TermReference)
-> Map Text TermReference
-> [BuiltinTypeDSL]
-> Map Text TermReference
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Map Text TermReference -> BuiltinTypeDSL -> Map Text TermReference
forall {h}.
Map Text (Reference' Text h)
-> BuiltinTypeDSL -> Map Text (Reference' Text h)
go Map Text TermReference
forall a. Monoid a => a
mempty [BuiltinTypeDSL]
builtinTypesSrc
  where
    go :: Map Text (Reference' Text h)
-> BuiltinTypeDSL -> Map Text (Reference' Text h)
go Map Text (Reference' Text h)
m = \case
      B' Text
r ConstructorType
_ -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
r (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Map Text (Reference' Text h)
m
      D' Text
r -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
r (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Map Text (Reference' Text h)
m
      Rename' Text
r Text
name -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
name Map Text (Reference' Text h)
m of
        Just Reference' Text h
_ ->
          String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
            Text
"tried to rename `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` to `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"`, "
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"which already exists."
        Maybe (Reference' Text h)
Nothing -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
r Map Text (Reference' Text h)
m of
          Maybe (Reference' Text h)
Nothing ->
            String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
              Text
"tried to rename `" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` before it was declared."
          Just Reference' Text h
t -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
name Reference' Text h
t (Map Text (Reference' Text h) -> Map Text (Reference' Text h))
-> (Map Text (Reference' Text h) -> Map Text (Reference' Text h))
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text
-> Map Text (Reference' Text h) -> Map Text (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete Text
r (Map Text (Reference' Text h) -> Map Text (Reference' Text h))
-> Map Text (Reference' Text h) -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$ Map Text (Reference' Text h)
m
      Alias' Text
r Text
name -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
name Map Text (Reference' Text h)
m of
        Just Reference' Text h
_ ->
          String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
            Text
"tried to alias `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` to `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"`, "
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"which already exists."
        Maybe (Reference' Text h)
Nothing -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
r Map Text (Reference' Text h)
m of
          Maybe (Reference' Text h)
Nothing ->
            String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
              Text
"tried to alias `" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` before it was declared."
          Just Reference' Text h
t -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
name Reference' Text h
t Map Text (Reference' Text h)
m

-- WARNING: Don't delete any of these lines, only add corrections.
builtinTypesSrc :: [BuiltinTypeDSL]
builtinTypesSrc :: [BuiltinTypeDSL]
builtinTypesSrc =
  [ Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Int" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Nat" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Float" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Boolean" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Sequence" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Sequence" Text
"List",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Text" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Pattern" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Char" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Effect" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Effect" Text
"Request",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Bytes" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Link.Term" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Link.Type" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"IO" ConstructorType
CT.Effect,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"IO" Text
"io2.IO",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Handle" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Handle" Text
"io2.Handle",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"ProcessHandle" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"ProcessHandle" Text
"io2.ProcessHandle",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Socket" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Socket" Text
"io2.Socket",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"ThreadId" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"ThreadId" Text
"io2.ThreadId",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"MVar" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"MVar" Text
"io2.MVar",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Code" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Value" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Any" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"crypto.HashAlgorithm" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls" Text
"io2.Tls",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls.ClientConfig" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls.ClientConfig" Text
"io2.Tls.ClientConfig",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls.ServerConfig" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls.ServerConfig" Text
"io2.Tls.ServerConfig",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls.SignedCert" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls.SignedCert" Text
"io2.Tls.SignedCert",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls.PrivateKey" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls.PrivateKey" Text
"io2.Tls.PrivateKey",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls.Version" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls.Version" Text
"io2.Tls.Version",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Tls.Cipher" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Tls.Cipher" Text
"io2.Tls.Cipher",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"TVar" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"TVar" Text
"io2.TVar",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"STM" ConstructorType
CT.Effect,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"STM" Text
"io2.STM",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Ref" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Scope" ConstructorType
CT.Effect,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Ref.Ticket" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Ref.Ticket" Text
"io2.Ref.Ticket",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Promise" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"Promise" Text
"io2.Promise",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"TimeSpec" ConstructorType
CT.Data,
    Text -> Text -> BuiltinTypeDSL
Rename' Text
"TimeSpec" Text
"io2.Clock.internals.TimeSpec",
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"ImmutableArray" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"MutableArray" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"ImmutableByteArray" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"MutableByteArray" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"Char.Class" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"UDPSocket" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"ListenSocket" ConstructorType
CT.Data,
    Text -> ConstructorType -> BuiltinTypeDSL
B' Text
"ClientSockAddr" ConstructorType
CT.Data
  ]

-- rename these to "builtin" later, when builtin means intrinsic as opposed to
-- stuff that intrinsics depend on.
intrinsicTypeReferences :: Set R.Reference
intrinsicTypeReferences :: Set TermReference
intrinsicTypeReferences = (Set TermReference -> BuiltinTypeDSL -> Set TermReference)
-> Set TermReference -> [BuiltinTypeDSL] -> Set TermReference
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Set TermReference -> BuiltinTypeDSL -> Set TermReference
forall {h}.
Ord h =>
Set (Reference' Text h)
-> BuiltinTypeDSL -> Set (Reference' Text h)
go Set TermReference
forall a. Monoid a => a
mempty [BuiltinTypeDSL]
builtinTypesSrc
  where
    go :: Set (Reference' Text h)
-> BuiltinTypeDSL -> Set (Reference' Text h)
go Set (Reference' Text h)
acc = \case
      B' Text
r ConstructorType
_ -> Reference' Text h
-> Set (Reference' Text h) -> Set (Reference' Text h)
forall a. Ord a => a -> Set a -> Set a
Set.insert (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Set (Reference' Text h)
acc
      D' Text
r -> Reference' Text h
-> Set (Reference' Text h) -> Set (Reference' Text h)
forall a. Ord a => a -> Set a -> Set a
Set.insert (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Set (Reference' Text h)
acc
      BuiltinTypeDSL
_ -> Set (Reference' Text h)
acc

intrinsicTermReferences :: Set R.Reference
intrinsicTermReferences :: Set TermReference
intrinsicTermReferences = Map TermReference Type -> Set TermReference
forall k a. Map k a -> Set k
Map.keysSet Map TermReference Type
termRefTypes

builtinConstructorType :: Map R.Reference CT.ConstructorType
builtinConstructorType :: Map TermReference ConstructorType
builtinConstructorType = [(TermReference, ConstructorType)]
-> Map TermReference ConstructorType
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Text -> TermReference
forall t h. t -> Reference' t h
R.Builtin Text
r, ConstructorType
ct) | B' Text
r ConstructorType
ct <- [BuiltinTypeDSL]
builtinTypesSrc]

data BuiltinTypeDSL = B' Text CT.ConstructorType | D' Text | Rename' Text Text | Alias' Text Text

data BuiltinDSL
  = -- simple builtin: name=ref, type
    B Text Type
  | -- deprecated builtin: name=ref, type (TBD)
    D Text Type
  | -- rename builtin: refname, newname
    -- must not appear before corresponding B/D
    -- will overwrite newname
    Rename Text Text
  | -- alias builtin: refname, newname
    -- must not appear before corresponding B/D
    -- will overwrite newname
    Alias Text Text

instance Show BuiltinDSL where
  show :: BuiltinDSL -> String
show (B Text
t Type
_) = Text -> String
Text.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Text
"B" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t
  show (Rename Text
from Text
to) = Text -> String
Text.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Text
"Rename " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
from Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" to " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
to
  show BuiltinDSL
_ = String
""

termNameRefs :: Map Name R.Reference
termNameRefs :: Map Name TermReference
termNameRefs = (Text -> Name) -> Map Text TermReference -> Map Name TermReference
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys HasCallStack => Text -> Name
Text -> Name
Name.unsafeParseText (Map Text TermReference -> Map Name TermReference)
-> Map Text TermReference -> Map Name TermReference
forall a b. (a -> b) -> a -> b
$ (Map Text TermReference -> BuiltinDSL -> Map Text TermReference)
-> Map Text TermReference -> [BuiltinDSL] -> Map Text TermReference
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Map Text TermReference -> BuiltinDSL -> Map Text TermReference
forall {h}.
Map Text (Reference' Text h)
-> BuiltinDSL -> Map Text (Reference' Text h)
go Map Text TermReference
forall a. Monoid a => a
mempty ([BuiltinDSL] -> [BuiltinDSL]
stripVersion [BuiltinDSL]
builtinsSrc)
  where
    go :: Map Text (Reference' Text h)
-> BuiltinDSL -> Map Text (Reference' Text h)
go Map Text (Reference' Text h)
m = \case
      B Text
r Type
_tp -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
r (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Map Text (Reference' Text h)
m
      D Text
r Type
_tp -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
r (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Map Text (Reference' Text h)
m
      Rename Text
r Text
name -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
name Map Text (Reference' Text h)
m of
        Just Reference' Text h
_ ->
          String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
            Text
"tried to rename `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` to `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"`, "
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"which already exists."
        Maybe (Reference' Text h)
Nothing -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
r Map Text (Reference' Text h)
m of
          Maybe (Reference' Text h)
Nothing ->
            String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
              Text
"tried to rename `" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` before it was declared."
          Just Reference' Text h
t -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
name Reference' Text h
t (Map Text (Reference' Text h) -> Map Text (Reference' Text h))
-> (Map Text (Reference' Text h) -> Map Text (Reference' Text h))
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text
-> Map Text (Reference' Text h) -> Map Text (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete Text
r (Map Text (Reference' Text h) -> Map Text (Reference' Text h))
-> Map Text (Reference' Text h) -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$ Map Text (Reference' Text h)
m
      Alias Text
r Text
name -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
name Map Text (Reference' Text h)
m of
        Just Reference' Text h
_ ->
          String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
            Text
"tried to alias `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` to `"
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"`, "
              Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"which already exists."
        Maybe (Reference' Text h)
Nothing -> case Text -> Map Text (Reference' Text h) -> Maybe (Reference' Text h)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
r Map Text (Reference' Text h)
m of
          Maybe (Reference' Text h)
Nothing ->
            String -> Map Text (Reference' Text h)
forall a. HasCallStack => String -> a
error (String -> Map Text (Reference' Text h))
-> (Text -> String) -> Text -> Map Text (Reference' Text h)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> Map Text (Reference' Text h))
-> Text -> Map Text (Reference' Text h)
forall a b. (a -> b) -> a -> b
$
              Text
"tried to alias `" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
r Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"` before it was declared."
          Just Reference' Text h
t -> Text
-> Reference' Text h
-> Map Text (Reference' Text h)
-> Map Text (Reference' Text h)
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Text
name Reference' Text h
t Map Text (Reference' Text h)
m

termRefTypes :: Map R.TermReference Type
termRefTypes :: Map TermReference Type
termRefTypes = (Map TermReference Type -> BuiltinDSL -> Map TermReference Type)
-> Map TermReference Type -> [BuiltinDSL] -> Map TermReference Type
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Map TermReference Type -> BuiltinDSL -> Map TermReference Type
forall {h}.
Ord h =>
Map (Reference' Text h) Type
-> BuiltinDSL -> Map (Reference' Text h) Type
go Map TermReference Type
forall a. Monoid a => a
mempty [BuiltinDSL]
builtinsSrc
  where
    go :: Map (Reference' Text h) Type
-> BuiltinDSL -> Map (Reference' Text h) Type
go Map (Reference' Text h) Type
m = \case
      B Text
r Type
t -> Reference' Text h
-> Type
-> Map (Reference' Text h) Type
-> Map (Reference' Text h) Type
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Type
t Map (Reference' Text h) Type
m
      D Text
r Type
t -> Reference' Text h
-> Type
-> Map (Reference' Text h) Type
-> Map (Reference' Text h) Type
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert (Text -> Reference' Text h
forall t h. t -> Reference' t h
R.Builtin Text
r) Type
t Map (Reference' Text h) Type
m
      BuiltinDSL
_ -> Map (Reference' Text h) Type
m

termRefTypeReferences :: Map R.TermReference R.TypeReference
termRefTypeReferences :: Map TermReference TermReference
termRefTypeReferences = Type -> TermReference
forall v a. Var v => Type v a -> TermReference
H.typeToReference (Type -> TermReference)
-> Map TermReference Type -> Map TermReference TermReference
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map TermReference Type
termRefTypes

typeOf :: a -> (Type -> a) -> R.Reference -> a
typeOf :: forall a. a -> (Type -> a) -> TermReference -> a
typeOf a
a Type -> a
f TermReference
r = a -> (Type -> a) -> Maybe Type -> a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe a
a Type -> a
f (TermReference -> Map TermReference Type -> Maybe Type
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup TermReference
r Map TermReference Type
termRefTypes)

builtinsSrc :: [BuiltinDSL]
builtinsSrc :: [BuiltinDSL]
builtinsSrc =
  [ Text -> Type -> BuiltinDSL
B Text
"Any.unsafeExtract" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
anyt Type -> Type -> Type
--> Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Int.+" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.-" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.*" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int./" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.<" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.>" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.<=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.>=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.==" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.and" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.or" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.xor" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.complement" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.increment" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.isEven" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.isOdd" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Int.signum" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.leadingZeros" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Int.negate" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.mod" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.pow" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.shiftLeft" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.shiftRight" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.truncate0" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Int.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Int.fromText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
optionalt Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.toFloat" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Int.trailingZeros" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Int.popCount" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Int.fromRepresentation" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Int.toRepresentation" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
int Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.*" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.+" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat./" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.<" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.<=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.==" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.>" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.>=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.and" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.or" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.xor" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.complement" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.drop" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.fromText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
optionalt Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.increment" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.isEven" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.isOdd" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Nat.leadingZeros" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.mod" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.pow" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.shiftLeft" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.shiftRight" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.sub" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Nat.toFloat" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Nat.toInt" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Nat.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Nat.trailingZeros" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Nat.popCount" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.decodeNat64be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
nat, Type
bytes]),
    Text -> Type -> BuiltinDSL
B Text
"Bytes.decodeNat64le" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
nat, Type
bytes]),
    Text -> Type -> BuiltinDSL
B Text
"Bytes.decodeNat32be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
nat, Type
bytes]),
    Text -> Type -> BuiltinDSL
B Text
"Bytes.decodeNat32le" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
nat, Type
bytes]),
    Text -> Type -> BuiltinDSL
B Text
"Bytes.decodeNat16be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
nat, Type
bytes]),
    Text -> Type -> BuiltinDSL
B Text
"Bytes.decodeNat16le" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
nat, Type
bytes]),
    Text -> Type -> BuiltinDSL
B Text
"Bytes.encodeNat64be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.encodeNat64le" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.encodeNat32be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.encodeNat32le" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.encodeNat16be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.encodeNat16le" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Float.+" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.-" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.*" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float./" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.<" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Float.>" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Float.<=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Float.>=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Float.==" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Float.fromRepresentation" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.toRepresentation" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
nat,
    -- Trigonmetric Functions
    Text -> Type -> BuiltinDSL
B Text
"Float.acos" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.asin" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.atan" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.atan2" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.cos" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.sin" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.tan" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    -- Hyperbolic Functions
    Text -> Type -> BuiltinDSL
B Text
"Float.acosh" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.asinh" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.atanh" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.cosh" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.sinh" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.tanh" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    -- Exponential Functions
    Text -> Type -> BuiltinDSL
B Text
"Float.exp" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.log" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.logBase" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    -- Power Functions
    Text -> Type -> BuiltinDSL
B Text
"Float.pow" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.sqrt" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    -- Rounding and Remainder Functions
    Text -> Type -> BuiltinDSL
B Text
"Float.ceiling" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Float.floor" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Float.round" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
int,
    Text -> Type -> BuiltinDSL
B Text
"Float.truncate" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
int,
    -- Float Utils
    Text -> Type -> BuiltinDSL
B Text
"Float.abs" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.max" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.min" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
float Type -> Type -> Type
--> Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Float.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
float Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Float.fromText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
optionalt Type
float,
    Text -> Type -> BuiltinDSL
B Text
"Universal.==" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean),
    -- Don't we want a Universal.!= ?

    -- Universal.compare intended as a low level function that just returns
    -- `Int` rather than some Ordering data type. If we want, later,
    -- could provide a pure Unison wrapper for Universal.compare that
    -- returns a proper data type.
    --
    -- 0 is equal, < 0 is less than, > 0 is greater than
    Text -> Type -> BuiltinDSL
B Text
"Universal.compare" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
int),
    Text -> Type -> BuiltinDSL
B Text
"Universal.>" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean),
    Text -> Type -> BuiltinDSL
B Text
"Universal.<" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean),
    Text -> Type -> BuiltinDSL
B Text
"Universal.>=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean),
    Text -> Type -> BuiltinDSL
B Text
"Universal.<=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean),
    Text -> Type -> BuiltinDSL
B Text
"Universal.murmurHash" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
nat),
    Text -> Type -> BuiltinDSL
B Text
"bug" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Text -> (Type -> Type) -> Type
forall1 Text
"b" (\Type
b -> Type
a Type -> Type -> Type
--> Type
b)),
    Text -> Type -> BuiltinDSL
B Text
"todo" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Text -> (Type -> Type) -> Type
forall1 Text
"b" (\Type
b -> Type
a Type -> Type -> Type
--> Type
b)),
    Text -> Type -> BuiltinDSL
B Text
"Any.Any" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type
anyt),
    Text -> Type -> BuiltinDSL
B Text
"Boolean.not" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
boolean Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Text.empty" Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.++" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.take" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.drop" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.indexOf" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
optionalt Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Text.size" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Text.repeat" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.==" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
D Text
"Text.!=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Text.<=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Text.>=" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Text.<" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Text.>" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"Text.uncons" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
char, Type
text]),
    Text -> Type -> BuiltinDSL
B Text
"Text.unsnoc" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type
text, Type
char]),
    Text -> Type -> BuiltinDSL
B Text
"Text.toCharList" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
list Type
char,
    Text -> Type -> BuiltinDSL
B Text
"Text.fromCharList" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
list Type
char Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.reverse" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.toUppercase" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.toLowercase" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.toUtf8" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Text.fromUtf8.impl.v3" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
failure Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.eof" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.anyChar" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
pat Type
text,
    -- Bytes.patterns.literal : Bytes -> Pattern Bytes
    -- Bytes.patterns.word64be : Nat -> Pattern Bytes
    -- Text.patterns.literal : Text -> Pattern Text
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.literal" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
text Type -> Type -> Type
--> Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.digit" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.letter" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.space" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.punctuation" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.charRange" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
char Type -> Type -> Type
--> Type
char Type -> Type -> Type
--> Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.notCharRange" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
char Type -> Type -> Type
--> Type
char Type -> Type -> Type
--> Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.charIn" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
list Type
char Type -> Type -> Type
--> Type -> Type
pat Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Text.patterns.notCharIn" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
list Type
char Type -> Type -> Type
--> Type -> Type
pat Type
text,
    -- Pattern.many : Pattern a -> Pattern a
    Text -> Type -> BuiltinDSL
B Text
"Pattern.many" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.many.corrected" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.replicate" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.capture" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.captureAs" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.join" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
list (Type -> Type
pat Type
a) Type -> Type -> Type
--> Type -> Type
pat Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.or" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a Type -> Type -> Type
--> Type -> Type
pat Type
a),
    -- Pattern.run : Pattern a -> a -> Optional ([a], a)
    Text -> Type -> BuiltinDSL
B Text
"Pattern.run" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
pat Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
optionalt ([Type] -> Type
tuple [Type -> Type
list Type
a, Type
a])),
    Text -> Type -> BuiltinDSL
B Text
"Pattern.isMatch" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
pat Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean),
    Text -> Type -> BuiltinDSL
B Text
"Char.toNat" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
char Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Char.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
char Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Char.fromNat" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
char,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.empty" Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.fromList" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
list Type
nat Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.++" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.take" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.drop" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.at" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
nat Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.indexOf" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type
optionalt Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.toList" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type
list Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.size" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.flatten" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.zlib.compress" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.zlib.decompress" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.gzip.compress" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.gzip.decompress" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
bytes,
    {- These are all `Bytes -> Bytes`, rather than `Bytes -> Text`.
       This is intentional: it avoids a round trip to `Text` if all
       you are doing with the bytes is dumping them to a file or a
       network socket.

       You can always `Text.fromUtf8` the results of these functions
       to get some `Text`.
     -}
    Text -> Type -> BuiltinDSL
B Text
"Bytes.toBase16" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.toBase32" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.toBase64" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.toBase64UrlUnpadded" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.fromBase16" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.fromBase32" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.fromBase64" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"Bytes.fromBase64UrlUnpadded" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
bytes,
    Text -> Type -> BuiltinDSL
D Text
"List.empty" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" Type -> Type
list,
    Text -> Type -> BuiltinDSL
B Text
"List.cons" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type -> Type
list Type
a Type -> Type -> Type
--> Type -> Type
list Type
a),
    Text -> Text -> BuiltinDSL
Alias Text
"List.cons" Text
"List.+:",
    Text -> Type -> BuiltinDSL
B Text
"List.snoc" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
list Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
list Type
a),
    Text -> Text -> BuiltinDSL
Alias Text
"List.snoc" Text
"List.:+",
    Text -> Type -> BuiltinDSL
B Text
"List.take" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
nat Type -> Type -> Type
--> Type -> Type
list Type
a Type -> Type -> Type
--> Type -> Type
list Type
a),
    Text -> Type -> BuiltinDSL
B Text
"List.drop" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
nat Type -> Type -> Type
--> Type -> Type
list Type
a Type -> Type -> Type
--> Type -> Type
list Type
a),
    Text -> Type -> BuiltinDSL
B Text
"List.++" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
list Type
a Type -> Type -> Type
--> Type -> Type
list Type
a Type -> Type -> Type
--> Type -> Type
list Type
a),
    Text -> Type -> BuiltinDSL
B Text
"List.size" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type -> Type
list Type
a Type -> Type -> Type
--> Type
nat),
    Text -> Type -> BuiltinDSL
B Text
"List.at" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
nat Type -> Type -> Type
--> Type -> Type
list Type
a Type -> Type -> Type
--> Type -> Type
optionalt Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Socket.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
socket Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Handle.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
handle Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"ThreadId.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
threadId Type -> Type -> Type
--> Type
text,
    Text -> Type -> BuiltinDSL
B Text
"Debug.watch" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
text Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Debug.trace" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
text Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
unit),
    Text -> Type -> BuiltinDSL
B Text
"Debug.toText" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
a Type -> Type -> Type
--> Type -> Type
optionalt (Type -> Type -> Type
eithert Type
text Type
text)),
    Text -> Type -> BuiltinDSL
B Text
"unsafe.coerceAbilities" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Text
-> Text
-> Text
-> Text
-> (Type -> Type -> Type -> Type -> Type)
-> Type
forall4 Text
"a" Text
"b" Text
"e1" Text
"e2" ((Type -> Type -> Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type -> Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a Type
b Type
e1 Type
e2 ->
        (Type
a Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
e1 Type
b) Type -> Type -> Type
--> (Type
a Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
e2 Type
b),
    Text -> Type -> BuiltinDSL
B Text
"Scope.run" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"r" Text
"g" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
r Type
g ->
      (Text -> (Type -> Type) -> Type
forall1 Text
"s" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
s -> Type
unit Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type -> Type
scopet Type
s, Type
g] Type
r) Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g Type
r,
    Text -> Type -> BuiltinDSL
B Text
"Scope.ref" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"a" Text
"s" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
a Type
s ->
      Type
a Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (Type -> Type
scopet Type
s) (Type -> Type -> Type
reft (() -> [Type] -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a
Type.effects () [Type -> Type
scopet Type
s]) Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Ref.read" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"a" Text
"g" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
a Type
g ->
      Type -> Type -> Type
reft Type
g Type
a Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g Type
a,
    Text -> Type -> BuiltinDSL
B Text
"Ref.write" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"a" Text
"g" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
a Type
g ->
      Type -> Type -> Type
reft Type
g Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableArray.size" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a -> Type -> Type -> Type
marrayt Type
g Type
a Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.size" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g -> Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableArray.size" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
iarrayt Type
a Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.size" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
ibytearrayt Type -> Type -> Type
--> Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableArray.copyTo!" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a ->
      Type -> Type -> Type
marrayt Type
g Type
a
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type -> Type -> Type
marrayt Type
g Type
a
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.copyTo!" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type -> Type
mbytearrayt Type
g
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableArray.read" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a ->
      Type -> Type -> Type
marrayt Type
g Type
a Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
a,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.read8" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.read16be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.read24be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.read32be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.read40be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.read64be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableArray.write" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a ->
      Type -> Type -> Type
marrayt Type
g Type
a Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.write8" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.write16be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.write32be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.write64be" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableArray.copyTo!" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a ->
      Type -> Type -> Type
marrayt Type
g Type
a
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type -> Type
iarrayt Type
a
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.copyTo!" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type
ibytearrayt
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> Type
nat
        Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [Type
g, () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
unit,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableArray.read" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
a ->
      Type -> Type
iarrayt Type
a Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
a,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.read8" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
ibytearrayt Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.read16be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
ibytearrayt Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.read24be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
ibytearrayt Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.read32be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
ibytearrayt Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.read40be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
ibytearrayt Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"ImmutableByteArray.read64be" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
ibytearrayt Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()) Type
nat,
    Text -> Type -> BuiltinDSL
B Text
"MutableArray.freeze!" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a ->
      Type -> Type -> Type
marrayt Type
g Type
a Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g (Type -> Type
iarrayt Type
a),
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.freeze!" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g Type
ibytearrayt,
    Text -> Type -> BuiltinDSL
B Text
"MutableArray.freeze" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"g" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g Type
a ->
      Type -> Type -> Type
marrayt Type
g Type
a Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g (Type -> Type
iarrayt Type
a),
    Text -> Type -> BuiltinDSL
B Text
"MutableByteArray.freeze" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"g" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
g ->
      Type -> Type
mbytearrayt Type
g Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () Type
g Type
ibytearrayt,
    Text -> Type -> BuiltinDSL
B Text
"Scope.array" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"s" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
s Type
a ->
      Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (Type -> Type
scopet Type
s) (Type -> Type -> Type
marrayt (Type -> Type
scopet Type
s) Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Scope.arrayOf" (Type -> BuiltinDSL)
-> ((Type -> Type -> Type) -> Type)
-> (Type -> Type -> Type)
-> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
"s" Text
"a" ((Type -> Type -> Type) -> BuiltinDSL)
-> (Type -> Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
s Type
a ->
      Type
a Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (Type -> Type
scopet Type
s) (Type -> Type -> Type
marrayt (Type -> Type
scopet Type
s) Type
a),
    Text -> Type -> BuiltinDSL
B Text
"Scope.bytearray" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"s" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
s ->
      Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (Type -> Type
scopet Type
s) (Type -> Type
mbytearrayt (Type -> Type
scopet Type
s)),
    Text -> Type -> BuiltinDSL
B Text
"Scope.bytearrayOf" (Type -> BuiltinDSL)
-> ((Type -> Type) -> Type) -> (Type -> Type) -> BuiltinDSL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> (Type -> Type) -> Type
forall1 Text
"s" ((Type -> Type) -> BuiltinDSL) -> (Type -> Type) -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ \Type
s ->
      Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (Type -> Type
scopet Type
s) (Type -> Type
mbytearrayt (Type -> Type
scopet Type
s)),
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.any" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.not" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
charClass Type -> Type -> Type
--> Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.and" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
charClass Type -> Type -> Type
--> Type
charClass Type -> Type -> Type
--> Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.or" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
charClass Type -> Type -> Type
--> Type
charClass Type -> Type -> Type
--> Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.range" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
char Type -> Type -> Type
--> Type
char Type -> Type -> Type
--> Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.anyOf" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type -> Type
list Type
char Type -> Type -> Type
--> Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.alphanumeric" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.upper" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.lower" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.whitespace" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.control" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.printable" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.mark" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.number" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.punctuation" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.symbol" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.separator" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.letter" Type
charClass,
    Text -> Type -> BuiltinDSL
B Text
"Char.Class.is" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
charClass
        Type -> Type -> Type
--> Type
char
        Type -> Type -> Type
--> Type
boolean,
    Text -> Type -> BuiltinDSL
B
      Text
"Text.patterns.char"
      (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
charClass Type -> Type -> Type
--> Type -> Type
pat Type
text
  ]
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++
    -- avoid name conflicts with Universal == < > <= >=
    [ Text -> Text -> BuiltinDSL
Rename (Text
t Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
old) (Text
t Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
new)
      | Text
t <- [Text
"Int", Text
"Nat", Text
"Float", Text
"Text"],
        (Text
old, Text
new) <-
          [ (Text
"==", Text
"eq"),
            (Text
"<", Text
"lt"),
            (Text
"<=", Text
"lteq"),
            (Text
">", Text
"gt"),
            (Text
">=", Text
"gteq")
          ]
    ]
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ Text -> [(Text, Type)] -> [BuiltinDSL]
moveUnder Text
"io2" [(Text, Type)]
ioBuiltins
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ Text -> [(Text, Type)] -> [BuiltinDSL]
moveUnder Text
"io2" [(Text, Type)]
mvarBuiltins
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ Text -> [(Text, Type)] -> [BuiltinDSL]
moveUnder Text
"io2" [(Text, Type)]
stmBuiltins
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ Text -> [(Text, Type)] -> [BuiltinDSL]
moveUnder Text
"io2" [(Text, Type)]
refPromiseBuiltins
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ [BuiltinDSL]
hashBuiltins
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ [BuiltinDSL]
cryptoBuiltins
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ ((Text, Type) -> BuiltinDSL) -> [(Text, Type)] -> [BuiltinDSL]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Text -> Type -> BuiltinDSL) -> (Text, Type) -> BuiltinDSL
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Text -> Type -> BuiltinDSL
B) [(Text, Type)]
codeBuiltins

moveUnder :: Text -> [(Text, Type)] -> [BuiltinDSL]
moveUnder :: Text -> [(Text, Type)] -> [BuiltinDSL]
moveUnder Text
prefix [(Text, Type)]
bs = [(Text, Type)]
bs [(Text, Type)] -> ((Text, Type) -> [BuiltinDSL]) -> [BuiltinDSL]
forall a b. [a] -> (a -> [b]) -> [b]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(Text
n, Type
ty) -> [Text -> Type -> BuiltinDSL
B Text
n Type
ty, Text -> Text -> BuiltinDSL
Rename Text
n (Text
prefix Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
n)]

-- builtins which have a version appended to their name (like the .v2 in IO.putBytes.v2)
-- Should be renamed to not have the version suffix
stripVersion :: [BuiltinDSL] -> [BuiltinDSL]
stripVersion :: [BuiltinDSL] -> [BuiltinDSL]
stripVersion [BuiltinDSL]
bs =
  [BuiltinDSL]
bs [BuiltinDSL] -> (BuiltinDSL -> [BuiltinDSL]) -> [BuiltinDSL]
forall a b. [a] -> (a -> [b]) -> [b]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= BuiltinDSL -> [BuiltinDSL]
rename
  where
    rename :: BuiltinDSL -> [BuiltinDSL]
    rename :: BuiltinDSL -> [BuiltinDSL]
rename o :: BuiltinDSL
o@(B Text
n Type
_) = BuiltinDSL -> Maybe (Text, MatchText Text, Text) -> [BuiltinDSL]
renameB BuiltinDSL
o (Maybe (Text, MatchText Text, Text) -> [BuiltinDSL])
-> Maybe (Text, MatchText Text, Text) -> [BuiltinDSL]
forall a b. (a -> b) -> a -> b
$ Regex -> Text -> Maybe (Text, MatchText Text, Text)
forall regex source.
RegexLike regex source =>
regex -> source -> Maybe (source, MatchText source, source)
RE.matchOnceText Regex
regex Text
n
    rename o :: BuiltinDSL
o@(Rename Text
_ Text
_) = [BuiltinDSL -> BuiltinDSL
renameRename BuiltinDSL
o]
    rename BuiltinDSL
o = [BuiltinDSL
o]

    -- When we see a B declaraiton, we add an additional Rename in the
    -- stream to rename it if it ahs a version string
    renameB :: BuiltinDSL -> Maybe (Text, RE.MatchText Text, Text) -> [BuiltinDSL]
    renameB :: BuiltinDSL -> Maybe (Text, MatchText Text, Text) -> [BuiltinDSL]
renameB o :: BuiltinDSL
o@(B Text
n Type
_) (Just (Text
before, MatchText Text
_, Text
_)) = [BuiltinDSL
o, Text -> Text -> BuiltinDSL
Rename Text
n Text
before]
    renameB (Rename Text
n Text
_) (Just (Text
before, MatchText Text
_, Text
_)) = [Text -> Text -> BuiltinDSL
Rename Text
n Text
before]
    renameB BuiltinDSL
x Maybe (Text, MatchText Text, Text)
_ = [BuiltinDSL
x]

    -- if there is already a Rename in the stream, then both sides of the
    -- rename need to have version stripped. This happens in when we move
    -- builtin IO to the io2 namespace, we might end up with:
    -- [ B IO.putBytes.v2 _, Rename IO.putBytes.v2 io2.IO.putBytes.v2]
    -- and would be become:
    -- [ B IO.putBytes.v2 _, Rename IO.putBytes.v2 IO.putBytes, Rename IO.putBytes io2.IO.putBytes ]
    renameRename :: BuiltinDSL -> BuiltinDSL
    renameRename :: BuiltinDSL -> BuiltinDSL
renameRename (Rename Text
before1 Text
before2) =
      let after1 :: Text
after1 = Text -> Maybe (Text, MatchText Text, Text) -> Text
renamed Text
before1 (Regex -> Text -> Maybe (Text, MatchText Text, Text)
forall regex source.
RegexLike regex source =>
regex -> source -> Maybe (source, MatchText source, source)
RE.matchOnceText Regex
regex Text
before1)
          after2 :: Text
after2 = Text -> Maybe (Text, MatchText Text, Text) -> Text
renamed Text
before2 (Regex -> Text -> Maybe (Text, MatchText Text, Text)
forall regex source.
RegexLike regex source =>
regex -> source -> Maybe (source, MatchText source, source)
RE.matchOnceText Regex
regex Text
before2)
       in Text -> Text -> BuiltinDSL
Rename Text
after1 Text
after2
    renameRename BuiltinDSL
x = BuiltinDSL
x

    renamed :: Text -> Maybe (Text, RE.MatchText Text, Text) -> Text
    renamed :: Text -> Maybe (Text, MatchText Text, Text) -> Text
renamed Text
_ (Just (Text
before, MatchText Text
_, Text
_)) = Text
before
    renamed Text
x Maybe (Text, MatchText Text, Text)
_ = Text
x

    r :: String
    r :: String
r = String
"\\.v[0-9]+"
    regex :: RE.Regex
    regex :: Regex
regex = CompOption -> ExecOption -> String -> Regex
forall regex compOpt execOpt source.
RegexMaker regex compOpt execOpt source =>
compOpt -> execOpt -> source -> regex
RE.makeRegexOpts (CompOption
forall regex compOpt execOpt.
RegexOptions regex compOpt execOpt =>
compOpt
RE.defaultCompOpt {RE.caseSensitive = False}) ExecOption
forall regex compOpt execOpt.
RegexOptions regex compOpt execOpt =>
execOpt
RE.defaultExecOpt String
r

hashBuiltins :: [BuiltinDSL]
hashBuiltins :: [BuiltinDSL]
hashBuiltins =
  [ Text -> Type -> BuiltinDSL
B Text
"crypto.hash" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
hashAlgo Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
bytes),
    Text -> Type -> BuiltinDSL
B Text
"crypto.hashBytes" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
hashAlgo Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"crypto.hmac" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Text -> (Type -> Type) -> Type
forall1 Text
"a" (\Type
a -> Type
hashAlgo Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
bytes),
    Text -> Type -> BuiltinDSL
B Text
"crypto.hmacBytes" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$ Type
hashAlgo Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes
  ]
    [BuiltinDSL] -> [BuiltinDSL] -> [BuiltinDSL]
forall a. [a] -> [a] -> [a]
++ (Text -> BuiltinDSL) -> [Text] -> [BuiltinDSL]
forall a b. (a -> b) -> [a] -> [b]
map Text -> BuiltinDSL
h [Text
"Sha3_512", Text
"Sha3_256", Text
"Sha2_512", Text
"Sha2_256", Text
"Sha1", Text
"Blake2b_512", Text
"Blake2b_256", Text
"Blake2s_256", Text
"Md5"]
  where
    hashAlgo :: Type
hashAlgo = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.hashAlgorithmRef
    h :: Text -> BuiltinDSL
h Text
name = Text -> Type -> BuiltinDSL
B (Text
"crypto.HashAlgorithm." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name) Type
hashAlgo

cryptoBuiltins :: [BuiltinDSL]
cryptoBuiltins :: [BuiltinDSL]
cryptoBuiltins =
  [ Text -> Type -> BuiltinDSL
B Text
"crypto.Ed25519.sign.impl" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
failure Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"crypto.Ed25519.verify.impl" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
failure Type
boolean,
    Text -> Type -> BuiltinDSL
B Text
"crypto.Rsa.sign.impl" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
failure Type
bytes,
    Text -> Type -> BuiltinDSL
B Text
"crypto.Rsa.verify.impl" (Type -> BuiltinDSL) -> Type -> BuiltinDSL
forall a b. (a -> b) -> a -> b
$
      Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
failure Type
boolean
  ]

ioBuiltins :: [(Text, Type)]
ioBuiltins :: [(Text, Type)]
ioBuiltins =
  [ (Text
"IO.openFile.impl.v3", Type
text Type -> Type -> Type
--> Type
fmode Type -> Type -> Type
--> Type -> Type
iof Type
handle),
    (Text
"IO.closeFile.impl.v3", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.isFileEOF.impl.v3", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.isFileOpen.impl.v3", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.isSeekable.impl.v3", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.seekHandle.impl.v3", Type
handle Type -> Type -> Type
--> Type
smode Type -> Type -> Type
--> Type
int Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.handlePosition.impl.v3", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
nat),
    (Text
"IO.getEnv.impl.v1", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
text),
    (Text
"IO.getArgs.impl.v1", Type
unit Type -> Type -> Type
--> Type -> Type
iof (Type -> Type
list Type
text)),
    (Text
"IO.getBuffering.impl.v3", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
bmode),
    (Text
"IO.setBuffering.impl.v3", Type
handle Type -> Type -> Type
--> Type
bmode Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.getChar.impl.v1", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
char),
    (Text
"IO.getEcho.impl.v1", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.ready.impl.v1", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.setEcho.impl.v1", Type
handle Type -> Type -> Type
--> Type
boolean Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.getBytes.impl.v3", Type
handle Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type -> Type
iof Type
bytes),
    (Text
"IO.getSomeBytes.impl.v1", Type
handle Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type -> Type
iof Type
bytes),
    (Text
"IO.putBytes.impl.v3", Type
handle Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.getLine.impl.v1", Type
handle Type -> Type -> Type
--> Type -> Type
iof Type
text),
    (Text
"IO.systemTime.impl.v3", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
nat),
    (Text
"IO.systemTimeMicroseconds.v1", Type
unit Type -> Type -> Type
--> Type -> Type
io Type
int),
    (Text
"IO.getTempDirectory.impl.v3", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
text),
    (Text
"IO.createTempDirectory.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
text),
    (Text
"IO.getCurrentDirectory.impl.v3", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
text),
    (Text
"IO.setCurrentDirectory.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.fileExists.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.isDirectory.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"IO.createDirectory.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.removeDirectory.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.renameDirectory.impl.v3", Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.directoryContents.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof (Type -> Type
list Type
text)),
    (Text
"IO.removeFile.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.renameFile.impl.v3", Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.getFileTimestamp.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
nat),
    (Text
"IO.getFileSize.impl.v3", Type
text Type -> Type -> Type
--> Type -> Type
iof Type
nat),
    (Text
"IO.serverSocket.impl.v3", Type -> Type
optionalt Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
iof Type
socket),
    (Text
"IO.listen.impl.v3", Type
socket Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.clientSocket.impl.v3", Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
iof Type
socket),
    (Text
"IO.UDP.clientSocket.impl.v1", Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
iof Type
udpSocket),
    (Text
"IO.UDP.ClientSockAddr.toText.v1", Type
udpClientSockAddr Type -> Type -> Type
--> Type
text),
    (Text
"IO.UDP.UDPSocket.toText.impl.v1", Type
udpSocket Type -> Type -> Type
--> Type
text),
    (Text
"IO.UDP.UDPSocket.close.impl.v1", Type
udpSocket Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.UDP.serverSocket.impl.v1", Type
text Type -> Type -> Type
--> Type
text Type -> Type -> Type
--> Type -> Type
iof Type
udpListenSocket),
    (Text
"IO.UDP.ListenSocket.recvFrom.impl.v1", Type
udpListenSocket Type -> Type -> Type
--> Type -> Type
iof ([Type] -> Type
tuple [Type
bytes, Type
udpClientSockAddr])),
    (Text
"IO.UDP.ListenSocket.sendTo.impl.v1", Type
udpListenSocket Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
udpClientSockAddr Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.UDP.ListenSocket.toText.impl.v1", Type
udpListenSocket Type -> Type -> Type
--> Type
text),
    (Text
"IO.UDP.ListenSocket.close.impl.v1", Type
udpListenSocket Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.UDP.UDPSocket.recv.impl.v1", Type
udpSocket Type -> Type -> Type
--> Type -> Type
iof Type
bytes),
    (Text
"IO.UDP.UDPSocket.send.impl.v1", Type
udpSocket Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.closeSocket.impl.v3", Type
socket Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.socketPort.impl.v3", Type
socket Type -> Type -> Type
--> Type -> Type
iof Type
nat),
    (Text
"IO.socketAccept.impl.v3", Type
socket Type -> Type -> Type
--> Type -> Type
iof Type
socket),
    (Text
"IO.socketSend.impl.v3", Type
socket Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.socketReceive.impl.v3", Type
socket Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type -> Type
iof Type
bytes),
    (Text
"IO.forkComp.v2", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> (Type
unit Type -> Type -> Type
--> Type -> Type
io Type
a) Type -> Type -> Type
--> Type -> Type
io Type
threadId),
    (Text
"IO.stdHandle", Type
stdhandle Type -> Type -> Type
--> Type
handle),
    (Text
"IO.delay.impl.v3", Type
nat Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"IO.kill.impl.v3", Type
threadId Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    ( Text
"IO.ref",
      Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a ->
        Type
a Type -> Type -> Type
--> Type -> Type
io (Type -> Type -> Type
reft Type
iot Type
a)
    ),
    (Text
"IO.process.call", Type
text Type -> Type -> Type
--> Type -> Type
list Type
text Type -> Type -> Type
--> Type -> Type
io Type
nat),
    ( Text
"IO.process.start",
      Type
text
        Type -> Type -> Type
--> Type -> Type
list Type
text
        Type -> Type -> Type
--> Type -> Type
io ([Type] -> Type
tuple [Type
handle, Type
handle, Type
handle, Type
phandle])
    ),
    (Text
"IO.process.kill", Type
phandle Type -> Type -> Type
--> Type -> Type
io Type
unit),
    (Text
"IO.process.wait", Type
phandle Type -> Type -> Type
--> Type -> Type
io Type
nat),
    (Text
"IO.process.exitCode", Type
phandle Type -> Type -> Type
--> Type -> Type
io (Type -> Type
optionalt Type
nat)),
    ( Text
"validateSandboxed",
      Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
list Type
termLink Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type
boolean
    ),
    (Text
"sandboxLinks", Type
termLink Type -> Type -> Type
--> Type -> Type
io (Type -> Type
list Type
termLink)),
    ( Text
"Value.validateSandboxed",
      Type -> Type
list Type
termLink
        Type -> Type -> Type
--> Type
value
        Type -> Type -> Type
--> Type -> Type
io (Type -> Type -> Type
eithert (Type -> Type
list Type
termLink) (Type -> Type
list Type
termLink))
    ),
    (Text
"Tls.newClient.impl.v3", Type
tlsClientConfig Type -> Type -> Type
--> Type
socket Type -> Type -> Type
--> Type -> Type
iof Type
tls),
    (Text
"Tls.newServer.impl.v3", Type
tlsServerConfig Type -> Type -> Type
--> Type
socket Type -> Type -> Type
--> Type -> Type
iof Type
tls),
    (Text
"Tls.handshake.impl.v3", Type
tls Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"Tls.send.impl.v3", Type
tls Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"Tls.decodeCert.impl.v3", Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
failure Type
tlsSignedCert),
    (Text
"Tls.encodeCert", Type
tlsSignedCert Type -> Type -> Type
--> Type
bytes),
    (Text
"Tls.decodePrivateKey", Type
bytes Type -> Type -> Type
--> Type -> Type
list Type
tlsPrivateKey),
    (Text
"Tls.encodePrivateKey", Type
tlsPrivateKey Type -> Type -> Type
--> Type
bytes),
    (Text
"Tls.receive.impl.v3", Type
tls Type -> Type -> Type
--> Type -> Type
iof Type
bytes),
    (Text
"Tls.terminate.impl.v3", Type
tls Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"Tls.ClientConfig.default", Type
text Type -> Type -> Type
--> Type
bytes Type -> Type -> Type
--> Type
tlsClientConfig),
    (Text
"Tls.ServerConfig.default", Type -> Type
list Type
tlsSignedCert Type -> Type -> Type
--> Type
tlsPrivateKey Type -> Type -> Type
--> Type
tlsServerConfig),
    (Text
"TLS.ClientConfig.ciphers.set", Type -> Type
list Type
tlsCipher Type -> Type -> Type
--> Type
tlsClientConfig Type -> Type -> Type
--> Type
tlsClientConfig),
    (Text
"Tls.ServerConfig.ciphers.set", Type -> Type
list Type
tlsCipher Type -> Type -> Type
--> Type
tlsServerConfig Type -> Type -> Type
--> Type
tlsServerConfig),
    (Text
"Tls.ClientConfig.certificates.set", Type -> Type
list Type
tlsSignedCert Type -> Type -> Type
--> Type
tlsClientConfig Type -> Type -> Type
--> Type
tlsClientConfig),
    (Text
"Tls.ServerConfig.certificates.set", Type -> Type
list Type
tlsSignedCert Type -> Type -> Type
--> Type
tlsServerConfig Type -> Type -> Type
--> Type
tlsServerConfig),
    (Text
"Tls.ClientConfig.versions.set", Type -> Type
list Type
tlsVersion Type -> Type -> Type
--> Type
tlsClientConfig Type -> Type -> Type
--> Type
tlsClientConfig),
    (Text
"Tls.ServerConfig.versions.set", Type -> Type
list Type
tlsVersion Type -> Type -> Type
--> Type
tlsServerConfig Type -> Type -> Type
--> Type
tlsServerConfig),
    (Text
"Clock.internals.monotonic.v1", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
timeSpec),
    (Text
"Clock.internals.processCPUTime.v1", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
timeSpec),
    (Text
"Clock.internals.threadCPUTime.v1", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
timeSpec),
    (Text
"Clock.internals.realtime.v1", Type
unit Type -> Type -> Type
--> Type -> Type
iof Type
timeSpec),
    (Text
"Clock.internals.sec.v1", Type
timeSpec Type -> Type -> Type
--> Type
int),
    (Text
"Clock.internals.nsec.v1", Type
timeSpec Type -> Type -> Type
--> Type
nat),
    (Text
"Clock.internals.systemTimeZone.v1", Type
int Type -> Type -> Type
--> Type -> Type
io ([Type] -> Type
tuple [Type
int, Type
nat, Type
text])),
    ( Text
"IO.array",
      Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a ->
        Type
nat Type -> Type -> Type
--> Type -> Type
io (Type -> Type -> Type
marrayt Type
iot Type
a)
    ),
    ( Text
"IO.arrayOf",
      Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a ->
        Type
a Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type -> Type
io (Type -> Type -> Type
marrayt Type
iot Type
a)
    ),
    ( Text
"IO.bytearray",
      Type
nat Type -> Type -> Type
--> Type -> Type
io (Type -> Type
mbytearrayt Type
iot)
    ),
    ( Text
"IO.bytearrayOf",
      Type
nat Type -> Type -> Type
--> Type
nat Type -> Type -> Type
--> Type -> Type
io (Type -> Type
mbytearrayt Type
iot)
    ),
    ( Text
"IO.tryEval",
      Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a ->
        (Type
unit Type -> Type -> Type
--> Type -> Type
io Type
a) Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect () [() -> Type
forall v a. Ord v => a -> Type v a
Type.builtinIO (), () -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()] Type
a
    ),
    (Text
"IO.randomBytes", Type
nat Type -> Type -> Type
--> Type -> Type
io Type
bytes)
  ]

mvarBuiltins :: [(Text, Type)]
mvarBuiltins :: [(Text, Type)]
mvarBuiltins =
  [ (Text
"MVar.new", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
a Type -> Type -> Type
--> Type -> Type
io (Type -> Type
mvar Type
a)),
    (Text
"MVar.newEmpty.v2", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
unit Type -> Type -> Type
--> Type -> Type
io (Type -> Type
mvar Type
a)),
    (Text
"MVar.take.impl.v3", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type -> Type
iof Type
a),
    (Text
"MVar.tryTake", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type -> Type
io (Type -> Type
optionalt Type
a)),
    (Text
"MVar.put.impl.v3", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
iof Type
unit),
    (Text
"MVar.tryPut.impl.v3", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
iof Type
boolean),
    (Text
"MVar.swap.impl.v3", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
iof Type
a),
    (Text
"MVar.isEmpty", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type -> Type
io Type
boolean),
    (Text
"MVar.read.impl.v3", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type -> Type
iof Type
a),
    (Text
"MVar.tryRead.impl.v3", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
mvar Type
a Type -> Type -> Type
--> Type -> Type
iof (Type -> Type
optionalt Type
a))
  ]
  where
    mvar :: Type -> Type
    mvar :: Type -> Type
mvar Type
a = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.mvarRef Type -> Type -> Type
`app` Type
a

codeBuiltins :: [(Text, Type)]
codeBuiltins :: [(Text, Type)]
codeBuiltins =
  [ (Text
"Code.dependencies", Type
code Type -> Type -> Type
--> Type -> Type
list Type
termLink),
    (Text
"Code.isMissing", Type
termLink Type -> Type -> Type
--> Type -> Type
io Type
boolean),
    (Text
"Code.serialize", Type
code Type -> Type -> Type
--> Type
bytes),
    (Text
"Code.deserialize", Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
code),
    (Text
"Code.cache_", Type -> Type
list ([Type] -> Type
tuple [Type
termLink, Type
code]) Type -> Type -> Type
--> Type -> Type
io (Type -> Type
list Type
termLink)),
    (Text
"Code.validate", Type -> Type
list ([Type] -> Type
tuple [Type
termLink, Type
code]) Type -> Type -> Type
--> Type -> Type
io (Type -> Type
optionalt Type
failure)),
    (Text
"Code.lookup", Type
termLink Type -> Type -> Type
--> Type -> Type
io (Type -> Type
optionalt Type
code)),
    (Text
"Code.display", Type
text Type -> Type -> Type
--> Type
code Type -> Type -> Type
--> Type
text),
    ( Text
"Code.validateLinks",
      Type -> Type
list ([Type] -> Type
tuple [Type
termLink, Type
code])
        Type -> Type -> Type
--> () -> [Type] -> Type -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a -> Type v a
Type.effect
          ()
          [() -> Type
forall v a. Ord v => a -> Type v a
DD.exceptionType ()]
          (Type -> Type -> Type
eithert (Type -> Type
list Type
termLink) (Type -> Type
list Type
termLink))
    ),
    (Text
"Value.dependencies", Type
value Type -> Type -> Type
--> Type -> Type
list Type
termLink),
    (Text
"Value.serialize", Type
value Type -> Type -> Type
--> Type
bytes),
    (Text
"Value.deserialize", Type
bytes Type -> Type -> Type
--> Type -> Type -> Type
eithert Type
text Type
value),
    (Text
"Value.value", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
a Type -> Type -> Type
--> Type
value),
    ( Text
"Value.load",
      Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
value Type -> Type -> Type
--> Type -> Type
io (Type -> Type -> Type
eithert (Type -> Type
list Type
termLink) Type
a)
    ),
    (Text
"Link.Term.toText", Type
termLink Type -> Type -> Type
--> Type
text)
  ]

stmBuiltins :: [(Text, Type)]
stmBuiltins :: [(Text, Type)]
stmBuiltins =
  [ (Text
"TVar.new", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
a Type -> Type -> Type
--> Type -> Type
stm (Type -> Type
tvar Type
a)),
    (Text
"TVar.newIO", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
a Type -> Type -> Type
--> Type -> Type
io (Type -> Type
tvar Type
a)),
    (Text
"TVar.read", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
tvar Type
a Type -> Type -> Type
--> Type -> Type
stm Type
a),
    (Text
"TVar.readIO", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
tvar Type
a Type -> Type -> Type
--> Type -> Type
io Type
a),
    (Text
"TVar.write", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
tvar Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
stm Type
unit),
    (Text
"TVar.swap", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
tvar Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
stm Type
a),
    (Text
"STM.retry", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
unit Type -> Type -> Type
--> Type -> Type
stm Type
a),
    (Text
"STM.atomically", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> (Type
unit Type -> Type -> Type
--> Type -> Type
stm Type
a) Type -> Type -> Type
--> Type -> Type
io Type
a)
  ]

refPromiseBuiltins :: [(Text, Type)]
refPromiseBuiltins :: [(Text, Type)]
refPromiseBuiltins =
  [ (Text
"Ref.Ticket.read", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
ticket Type
a Type -> Type -> Type
--> Type
a),
    (Text
"Ref.readForCas", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type -> Type
reft Type
iot Type
a Type -> Type -> Type
--> Type -> Type
io (Type -> Type
ticket Type
a)),
    (Text
"Ref.cas", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type -> Type
reft Type
iot Type
a Type -> Type -> Type
--> Type -> Type
ticket Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
io Type
boolean),
    (Text
"Promise.new", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type
unit Type -> Type -> Type
--> Type -> Type
io (Type -> Type
promise Type
a)),
    (Text
"Promise.read", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
promise Type
a Type -> Type -> Type
--> Type -> Type
io Type
a),
    (Text
"Promise.tryRead", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
promise Type
a Type -> Type -> Type
--> Type -> Type
io (Type -> Type
optionalt Type
a)),
    (Text
"Promise.write", Text -> (Type -> Type) -> Type
forall1 Text
"a" ((Type -> Type) -> Type) -> (Type -> Type) -> Type
forall a b. (a -> b) -> a -> b
$ \Type
a -> Type -> Type
promise Type
a Type -> Type -> Type
--> Type
a Type -> Type -> Type
--> Type -> Type
io Type
boolean)
  ]
  where
    ticket :: Type -> Type
    ticket :: Type -> Type
ticket Type
a = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.ticketRef Type -> Type -> Type
`app` Type
a
    promise :: Type -> Type
    promise :: Type -> Type
promise Type
a = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.promiseRef Type -> Type -> Type
`app` Type
a

forall1 :: Text -> (Type -> Type) -> Type
forall1 :: Text -> (Type -> Type) -> Type
forall1 Text
name Type -> Type
body =
  let a :: Symbol
a = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
name
   in () -> Symbol -> Type -> Type
forall v a. Ord v => a -> v -> Type v a -> Type v a
Type.forAll () Symbol
a (Type -> Type
body (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
a)

forall2 ::
  Text -> Text -> (Type -> Type -> Type) -> Type
forall2 :: Text -> Text -> (Type -> Type -> Type) -> Type
forall2 Text
na Text
nb Type -> Type -> Type
body = () -> [Symbol] -> Type -> Type
forall v a. Ord v => a -> [v] -> Type v a -> Type v a
Type.foralls () [Symbol
a, Symbol
b] (Type -> Type -> Type
body Type
ta Type
tb)
  where
    a :: Symbol
a = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
na
    b :: Symbol
b = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
nb
    ta :: Type
ta = () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
a
    tb :: Type
tb = () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
b

forall4 ::
  Text ->
  Text ->
  Text ->
  Text ->
  (Type -> Type -> Type -> Type -> Type) ->
  Type
forall4 :: Text
-> Text
-> Text
-> Text
-> (Type -> Type -> Type -> Type -> Type)
-> Type
forall4 Text
na Text
nb Text
nc Text
nd Type -> Type -> Type -> Type -> Type
body = () -> [Symbol] -> Type -> Type
forall v a. Ord v => a -> [v] -> Type v a -> Type v a
Type.foralls () [Symbol
a, Symbol
b, Symbol
c, Symbol
d] (Type -> Type -> Type -> Type -> Type
body Type
ta Type
tb Type
tc Type
td)
  where
    a :: Symbol
a = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
na
    b :: Symbol
b = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
nb
    c :: Symbol
c = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
nc
    d :: Symbol
d = Text -> Symbol
forall v. Var v => Text -> v
Var.named Text
nd
    ta :: Type
ta = () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
a
    tb :: Type
tb = () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
b
    tc :: Type
tc = () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
c
    td :: Type
td = () -> Symbol -> Type
forall v a. Ord v => a -> v -> Type v a
Type.var () Symbol
d

app :: Type -> Type -> Type
app :: Type -> Type -> Type
app = () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.app ()

list :: Type -> Type
list :: Type -> Type
list Type
arg = () -> Type
forall v a. Ord v => a -> Type v a
Type.list () Type -> Type -> Type
`app` Type
arg

optionalt :: Type -> Type
optionalt :: Type -> Type
optionalt Type
arg = () -> Type
forall v a. Ord v => a -> Type v a
DD.optionalType () Type -> Type -> Type
`app` Type
arg

tuple :: [Type] -> Type
tuple :: [Type] -> Type
tuple [Type
t] = Type
t
tuple [Type]
ts = (Type -> Type -> Type) -> Type -> [Type] -> Type
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Type -> Type -> Type
pair (() -> Type
forall v a. Ord v => a -> Type v a
DD.unitType ()) [Type]
ts

pair :: Type -> Type -> Type
pair :: Type -> Type -> Type
pair Type
l Type
r = () -> Type
forall v a. Ord v => a -> Type v a
DD.pairType () Type -> Type -> Type
`app` Type
l Type -> Type -> Type
`app` Type
r

(-->) :: Type -> Type -> Type
Type
a --> :: Type -> Type -> Type
--> Type
b = () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.arrow () Type
a Type
b

infixr 9 -->

io, iof :: Type -> Type
io :: Type -> Type
io = () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> Type
forall v a. Ord v => a -> Type v a
Type.builtinIO ())
iof :: Type -> Type
iof = Type -> Type
io (Type -> Type) -> (Type -> Type) -> Type -> Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Type -> Type -> Type
eithert Type
failure

iot :: Type
iot :: Type
iot = (() -> [Type] -> Type
forall v a. Ord v => a -> [Type v a] -> Type v a
Type.effects () [() -> Type
forall v a. Ord v => a -> Type v a
Type.builtinIO ()])

failure :: Type
failure :: Type
failure = () -> Type
forall v a. Ord v => a -> Type v a
DD.failureType ()

eithert :: Type -> Type -> Type
eithert :: Type -> Type -> Type
eithert Type
l Type
r = () -> Type
forall v a. Ord v => a -> Type v a
DD.eitherType () Type -> Type -> Type
`app` Type
l Type -> Type -> Type
`app` Type
r

scopet :: Type -> Type
scopet :: Type -> Type
scopet Type
s = () -> Type
forall v a. Ord v => a -> Type v a
Type.scopeType () Type -> Type -> Type
`app` Type
s

reft :: Type -> Type -> Type
reft :: Type -> Type -> Type
reft Type
s Type
a = () -> Type
forall v a. Ord v => a -> Type v a
Type.refType () Type -> Type -> Type
`app` Type
s Type -> Type -> Type
`app` Type
a

ibytearrayt :: Type
ibytearrayt :: Type
ibytearrayt = () -> Type
forall v a. Ord v => a -> Type v a
Type.ibytearrayType ()

mbytearrayt :: Type -> Type
mbytearrayt :: Type -> Type
mbytearrayt Type
g = () -> Type
forall v a. Ord v => a -> Type v a
Type.mbytearrayType () Type -> Type -> Type
`app` Type
g

iarrayt :: Type -> Type
iarrayt :: Type -> Type
iarrayt Type
a = () -> Type
forall v a. Ord v => a -> Type v a
Type.iarrayType () Type -> Type -> Type
`app` Type
a

marrayt :: Type -> Type -> Type
marrayt :: Type -> Type -> Type
marrayt Type
g Type
a = () -> Type
forall v a. Ord v => a -> Type v a
Type.marrayType () Type -> Type -> Type
`app` Type
g Type -> Type -> Type
`app` Type
a

socket, threadId, handle, phandle, unit :: Type
socket :: Type
socket = () -> Type
forall v a. Ord v => a -> Type v a
Type.socket ()
threadId :: Type
threadId = () -> Type
forall v a. Ord v => a -> Type v a
Type.threadId ()
handle :: Type
handle = () -> Type
forall v a. Ord v => a -> Type v a
Type.fileHandle ()
phandle :: Type
phandle = () -> Type
forall v a. Ord v => a -> Type v a
Type.processHandle ()
unit :: Type
unit = () -> Type
forall v a. Ord v => a -> Type v a
DD.unitType ()

udpSocket, udpListenSocket, udpClientSockAddr :: Type
udpSocket :: Type
udpSocket = () -> Type
forall v a. Ord v => a -> Type v a
Type.udpSocket ()
udpListenSocket :: Type
udpListenSocket = () -> Type
forall v a. Ord v => a -> Type v a
Type.udpListenSocket ()
udpClientSockAddr :: Type
udpClientSockAddr = () -> Type
forall v a. Ord v => a -> Type v a
Type.udpClientSockAddr ()

tls, tlsClientConfig, tlsServerConfig, tlsSignedCert, tlsPrivateKey, tlsVersion, tlsCipher :: Type
tls :: Type
tls = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsRef
tlsClientConfig :: Type
tlsClientConfig = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsClientConfigRef
tlsServerConfig :: Type
tlsServerConfig = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsServerConfigRef
tlsSignedCert :: Type
tlsSignedCert = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsSignedCertRef
tlsPrivateKey :: Type
tlsPrivateKey = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsPrivateKeyRef
tlsVersion :: Type
tlsVersion = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsVersionRef
tlsCipher :: Type
tlsCipher = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tlsCipherRef

fmode, bmode, smode, stdhandle :: Type
fmode :: Type
fmode = () -> Type
forall v a. Ord v => a -> Type v a
DD.fileModeType ()
bmode :: Type
bmode = () -> Type
forall v a. Ord v => a -> Type v a
DD.bufferModeType ()
smode :: Type
smode = () -> Type
forall v a. Ord v => a -> Type v a
DD.seekModeType ()
stdhandle :: Type
stdhandle = () -> Type
forall v a. Ord v => a -> Type v a
DD.stdHandleType ()

int, nat, bytes, text, boolean, float, char :: Type
int :: Type
int = () -> Type
forall v a. Ord v => a -> Type v a
Type.int ()
nat :: Type
nat = () -> Type
forall v a. Ord v => a -> Type v a
Type.nat ()
bytes :: Type
bytes = () -> Type
forall v a. Ord v => a -> Type v a
Type.bytes ()
text :: Type
text = () -> Type
forall v a. Ord v => a -> Type v a
Type.text ()
boolean :: Type
boolean = () -> Type
forall v a. Ord v => a -> Type v a
Type.boolean ()
float :: Type
float = () -> Type
forall v a. Ord v => a -> Type v a
Type.float ()
char :: Type
char = () -> Type
forall v a. Ord v => a -> Type v a
Type.char ()

anyt, code, value, termLink :: Type
anyt :: Type
anyt = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.anyRef
code :: Type
code = () -> Type
forall v a. Ord v => a -> Type v a
Type.code ()
value :: Type
value = () -> Type
forall v a. Ord v => a -> Type v a
Type.value ()
termLink :: Type
termLink = () -> Type
forall v a. Ord v => a -> Type v a
Type.termLink ()

stm, tvar, pat :: Type -> Type
stm :: Type -> Type
stm = () -> Type -> Type -> Type
forall v a. Ord v => a -> Type v a -> Type v a -> Type v a
Type.effect1 () (() -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.stmRef)
tvar :: Type -> Type
tvar Type
a = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.tvarRef Type -> Type -> Type
`app` Type
a
pat :: Type -> Type
pat Type
a = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.patternRef Type -> Type -> Type
`app` Type
a

charClass :: Type
charClass :: Type
charClass = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.charClassRef

timeSpec :: Type
timeSpec :: Type
timeSpec = () -> TermReference -> Type
forall v a. Ord v => a -> TermReference -> Type v a
Type.ref () TermReference
Type.timeSpecRef