Hello. I am stuck on a probably simple type problem and was wondering if
someone could help:

I'll just give the actual functions im using:

```
(struct Character ([bytes16 : Bytes]))
(define substr (make-bytes 128))
(: make-character (-> Integer Integer Character))
(define (make-character s e)
  (Character (subbytes substr (* 2 s) (* 2 e))))
```

What i want is a function like:

```
(: blah (-> (List Integer Integer) Character))
(define blah (λ (rng) (apply make-character rng)))
```

Which works.

But note i can't just type (λ (rng) (apply make-character rng)) into the
REPL, because i get:

; readline-input:5:14: Type Checker: Bad arguments to function in `apply':
; Domain: Integer Integer
; Arguments:  Any
;   in: (apply make-character rng)

I think because i need the explicit (List Integer Integer) annotation to
unify with (Listof Integer)

Anyway, i wanted to make my code simpler so i was wondering if i could
curry and partially apply. So i was digging around in the reference and
tried:

```
(: blah2 (-> (List Integer Integer) Character))
(define2 blah2 ((curry (inst apply Integer Character)) make-character)
```

But i get:

; readline-input:8:40: Type Checker: type mismatch
;   expected: (-> Integer * Character)
;   given: (-> Integer Integer Character)
;   in: make-character

Looking at the typed racket reference and the type of apply, thought the
star meant i could have many integers. Actually to be honest the discussion
in typed racket reference "1.6 - Other Type Constructors" left me hanging a
little bit on the function types, I am a pretty green on working with
racket types and types in general. I thought this would unify but i guess i
am completely wrong. Does anyone know what i am doing wrong exactly or what
a very abbreviated form for what i want (behavior of blah) is?

Sorry if this is basic i am a little lost on it as you can probably tell.

Thank you

Nate

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAM-xLPquALj6fqfxMhBuq402AAd4CNUCnxx2BvY0sQ2L4QOwog%40mail.gmail.com.

Reply via email to