Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Programming contest: Type checker.

Name: Anonymous 2011-11-03 8:09

Task: Write a type checker and inference engine for this small statically typed language (parser and evaluator optional. You may enter the AST directly in the source code, and you only need to ensure that invalid programs are failed and valid ones are passed).


; def: (def symbol arguments code), (def symbol code) or (def symbol)
; ∀: (∀ (variables) ((constraints)) code) returns code
; ∷: (∷ symbol type) returns symbol, type-annotated.
; →: (→ type1 type2 … returnType) returns type
; #+: primitive + of type (→ Int Int Int)

(def (∷ + (→ Int Int)) (x) x)
(def (∀ (χ) ((∷ + (→ Int . χ))) (∷ + (→ Int Int . χ)))
    (x y . r) (+ (#+ x y) . r)))

; (+ 1 1 1) → 3
; (+ 1 1 1 1) → 4
; ((+ 1) 1) → 2 (the language is curried)

; Interface example, assume an IO monad, String, write and sprintf:
(def (∷ Writeable (∀ (χ) ((∷ write (→ χ String (IO ())))) χ)))
(def (∷ fprintf (∀ (χ α) ((∷ Writeable χ) (∷ sprintf (→ ,@α String))) (→ χ ,@α (IO ()))))
    (a . b) (write a (sprintf . b))

Everything type annotation except the interface example should be able to be inferred. Feel free to improve the syntax of types that now use unquote-splicing as long as the semantics are the same.

The winner will be decided on the 1st of January. Criterions will be code size, elegance, helpfulness of error messages, and speed.

Name: Anonymous 2011-11-03 8:13

2011
using sexp syntax instead of mlite for typed lambda calculi

laughingirls.jpg

Name: Anonymous 2011-11-03 8:17

oh fuck no, the hellish type system of haskell combined with the readability of lisp

Name: Anonymous 2011-11-03 8:17

what a fucking miserable attempt at describing a type system.

Name: Anonymous 2011-11-03 8:37

>>2
mlite?

Name: what 2011-11-03 8:50

why is there math near my /g/

Name: Anonymous 2011-11-03 9:12

>>2
If you mean something like ML, then it's partly because SEXP has an easier AST for the purposes of this contest. Also, I think it will be a lot sexier with SRFI 49 and without type annotations.

>>4
Was there something you failed to understand?

Name: Anonymous 2011-11-03 9:15

the fuck am i looking at

Name: Anonymous 2011-11-03 10:08

>>7
SEXP has an easier AST

SEXP has an easier AST

SEXP has an easier AST

What


the


fuck


am


I










reading


???


Are you seriously this stupid? really???

Name: Anonymous 2011-11-03 10:11

>>7
you haven't explained the type rules, you just gave the (horrible horrible) syntax and a couple examples

Name: Anonymous 2011-11-03 10:13

nominated for /prog/ worst thread of 2011

Name: Anonymous 2011-11-03 10:14

(def (∷ Writeable (∀ (χ) ((∷ write (→ χ String (IO ())))) χ)))
(def (∷ Writeable (∀ (χ)
(def (∷ Writeable (∀
Writeable (∀
(∀

(゚∀゚)

Name: Anonymous 2011-11-03 11:03

>>10
What exactly isn't obvious? There's ad-hoc polymorphism, types are the same types as in System F, (∀ (α) ((constraints)) …) means every type α matching the constraints, the … can be replaced by any code and denotes the scope of those type variables, a constraint (∷ x <type containing variable(s)>)) means that the type variable in the ∀ is constrained to only types matching the type signatures of that symbol, how (→ Int . χ) and (→ χ ,@α String) constrains the variables should be plainly obvious, etc. etc. It's serioulsy straight forward, and if I've fucked up and there's an ambiguity, just ask.

>>9
Yeah, whatever, so SEXP is really a serialization of the AST of the underlying language, whatever. Does it matter for the contest at hand? Thought not.

Name: Anonymous 2011-11-03 11:08

>>9-11
Go back to /lounge/ or /b/

Name: Anonymous 2011-11-03 12:19

>>14
( ° ∀° )

Name: Anonymous 2011-11-03 12:21

[parentheses [give [me [a [huge [autistic [boneresque [boner 'powered-by-bbcode]]]]]]]]

Name: Anonymous 2011-11-03 15:06

Somebody translate this into something I can understand, like Bonerlang

Name: Anonymous 2011-11-03 19:49

>>13
lol mad and stupid

Name: Anonymous 2011-11-03 20:39


#include <boner.h>

boner boner(boner boner, boner* boner[])
{
    boner(boner, "Boner\n");
    boner boner;
}

Name: Anonymous 2011-11-03 20:40


use döner;

döner
    döner = döner;

döner
    döner("döner");
    döner döner;
döner;

Name: Anonymous 2011-11-03 22:14

bonerlang's type system is weak without BONADS

Name: Anonymous 2011-11-03 23:20


polecat kebabs polecat kebabs(polecat kebabs polecat kebabs)
    polecat kebabs << "polecat kebabs" << polecat kebabs;
polecat kebabs;

#polecat kebabs "polecat kebabs"
polecat kebabs(polecat kebabs polecat kebabs)
{
   polecat kebabs(polecat kebabs << polecat kebabs);
   polecat kebabs;
}

Name: Anonymous 2011-12-20 8:31

Time is running out!

Name: Anonymous 2011-12-20 8:58

It looks awful, I will not give life to this thing.

Name: Anonymous 2011-12-20 9:24

static typing
Thanks but I write programs to solve novel problems not reimplement the solutions of others.

Name: Anonymous 2011-12-20 10:19

Here you have:

(let ((validate-code (lambda () (display "Invalid code!")
                                (newline)
                                (exit 1))))
  (validate-code))

Name: Anonymous 2011-12-20 19:40

>>21
It should actually be that Bonerlang makes use of [b][i][o][u]GONADS[/u/][/o][/i][/b]

Don't change these.
Name: Email:
Entire Thread Thread List