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

A Haskell I can get behind

Name: Anonymous 2015-12-27 15:41

Name: Anonymous 2015-12-27 15:50

2007

Name: Anonymous 2015-12-27 16:17

a haskell in every pot everyday

Name: Anonymous 2015-12-27 17:02

Programming in Cummm Haskell

Name: Anonymous 2015-12-27 19:08

Now write Haskell in C macros

Name: Anonymous 2015-12-27 20:40

get behind

Do you want to bugger Haskell Curry, ya necrohomophiliac faggot?

Name: Anonymous 2015-12-28 15:22

>>6
Do you want to bugger Haskell Curry, ya necrohomophiliac faggot?
I think it'd be more of a bestiality thing.

Name: Anonymous 2015-12-28 17:13

>>6,7
You are both right girls.

Name: Anonymous 2015-12-28 23:28

The epitome of pointlessness applied to the most pointless language in existence.

Name: Anonymous 2016-01-03 17:36

>>5
C macros are turing complete.
The only thing preventing Haskell-in-C-Macros is that
i have no idea of high-level functions use cases(i use loops and function composition macros) in C.
If you explain the usefulness of something in Haskell and
what it replaces in C i could add it to some subheader in void.h, like e.g. haskell.h(even if its mostly useless)
http://w11.zetaboards.com/frozenbbs/forum/4210246/

Name: Anonymous 2016-01-03 18:33

>>10
The simplest example would be modifiedCollection = fmap f collection. Here there are no indices, and collection could be anything from a linked list to array to tree to hash-table, with any type of element as long as function f has one argument of the same type as the collection's elements. The result is a new collection of same type (but possibly different type of elements - the same as f's return type) and same number of elements.
I don't even know how to do that in C without using type-unsafe (void *) function pointers. You probably would need some _generic keywords to branch on the collection type.

Name: Anonymous 2016-01-03 18:39

>>11
Hold on, first the basics. I don't know anything
about Haskell(besides that it chains functions cryptically).
does fmap in haskell work like anything in this header?
http://w11.zetaboards.com/frozenbbs/topic/10957067/

Name: Anonymous 2016-01-03 18:45

>>12
Yes, it works like map(A,func), but that one's for arrays only. How would you go about abstracting it to different collection types like trees and hash-maps? Also is the func just a (void *) pointer, or does its type actually get checked when it's applied to func(A[i])?

Name: Anonymous 2016-01-03 18:51

>>13

func is typically a macro(_Generic) which selects either another macro or function.
all of the below is mem.h
#define foreach(iter,arr) for(u8 iter=0,elms_##iter=elems(arr);iter<elms_##iter;iter++)//}

#define size1(arg1) ({u8 lensize=sizeof(arg1);\
once;\
if((lensize!=sizeof(vp)))break;\
if(isarray(arg1)|isbasic(arg1)){;break;};\
lensize=msize((vp)(u8)arg1);endonce;\
;lensize;})

#define size(...) sum(apply(size1,__VA_ARGS__))

//{elements in array/ptr,clone(obj)
#define elems(arg) (size(arg)/sizeof(arg[0]))

Name: Anonymous 2016-01-03 18:54

>>10-12,14
Infinite compression!

Name: Anonymous 2016-01-03 19:07

the problem with writing more generic foreach, it would be
far less elegant than just writing foreach_hashmap/foreach_treenode iterators since they're far
more complex than array++ and void.h has nothing beside arrays.

Name: Anonymous 2016-01-03 19:18

So am i right?
What fmap does is
1.just selects a structure iterator(probably can be done via _Generic or __builtin_choose_expr/__builtin_types_compatible_p
2.iterate trough it and apply function (for_each(i in a) func(a[i])
nothing mindblowing yet.
But what if i wrote my own structure, does fmap
construct an iterator on its own?
Is fmap hardcoded for haskell structures only?
i.e. its giant switch with all thousands of possible structures and object or its some interface to iterators
which is fundamental to haskell?

Name: Anonymous 2016-01-03 19:44

>>17
In Haskell, you have to write an fmap implementation for every datastructure. It's called "typeclasses" - fmap is a typeclass method and if you want a type to become a member of that typeclass, you provide an implementation of fmap for that specific type. It's kind of like virtual methods in Sepples but more efficient because static. Most of method resolution happens at compile time as opposed to C++ where there's a runtime v-table indirection for every virtual call.

i.e. its giant switch with all thousands of possible structures and object or its some interface to iterators
More like the latter. Basically, for every type there's a compile-time dictionary of function pointers and when the typechecker figures out the type of the thing fmap is applied to, it chooses the right dictionary and substitutes fmap with the function from that dictionary (fmap_hashmap or fmap_treenode or whatever). Then sometimes it has to keep that dictionary until runtime and then it's pretty much v-tables - you can simulate C++ objects in Haskell like that.

If fmap doesn't look mindblowing to you, then I guess you could implement folds too. Then you could do lazy evaluation, obviously. So probably the only thing preventing a Haskell in C macros is that you'd have to write a GC implementation there.

Name: Anonymous 2016-01-03 19:55

>>18
fmap is easily doable without any GC.
#define iterator(obj,i) _Generic ( obj , hugelistof_all_posible_structures:nextmember(obj,i))

is the below macro(argmacro.h subheader) lazy eval?
//macro chain,fail to terminate
#define mch(func,args...) opapply(&&,func,args)

Name: Anonymous 2016-01-03 20:08

opapply is defined here(its just inserts operators between arguments)
http://w11.zetaboards.com/frozenbbs/topic/11177313/

Name: Anonymous 2016-01-03 21:42

>>18
Most of method resolution happens at compile time as opposed to C++ where there's a runtime v-table indirection for every virtual call.
No polymorphism, no static linking to binaries. Haskell is garbage.

Name: Anonymous 2016-01-03 21:51

dubs i can get behind

Name: Anonymous 2016-01-03 21:53

Name: Anonymous 2016-01-04 2:25

Name: Anonymous 2016-01-04 3:10

>>10
C macros are turing complete.

LOL, no they aren't, you deluded dick. Your macros are performing zero computation. They're just configuring the C source code which will compute in the future. No computation is being performed by the preprocessor, and no loops are even possible in C macros.

Now on the other hand, C++ templates are Turing Complete, and you can create all sorts of fully compile-time programs with them. It's fucking insane, but possible.

Name: Anonymous 2016-01-04 3:41

Delude my dick

Name: Anonymous 2016-01-04 4:31

check my dubs

Name: Anonymous 2016-01-04 5:32

>>25
I don't like templates. Macros are elegant and zero-cost:
the exact why "configuring the C source code which will compute in the future" is so powerful.

Name: Anonymous 2016-01-04 6:43

Name: Anonymous 2016-01-04 7:12

>>29
varmacro.h does a similar approach with VFUNC selector
Its limited to 63 arguments but way shorter/faster than any recursion. I could add e.g. 1024 arguments, but i never use that much.
http://w11.zetaboards.com/frozenbbs/topic/10910605/

Name: Anonymous 2016-01-04 8:13

Name: Anonymous 2016-01-04 9:17

Haskell/Lisp however have one crucial advantage: they're easier to debug and have type safety/syntax checking.
C macros are arbitrary text tokens and lack any sanity checks.

Name: Anonymous 2016-01-04 9:26

>>32
Technically, a no-macro version of void.h is possible
with some C++ tricks(using C++11/C++14 features) which
would be strictly typechecked and syntax checked.
Its no fun though, its basically forcing C++ to run
functional code with ugly template/constexpr/recursion combination that could be done by a single unsafe macro.

Name: Anonymous 2016-01-04 10:03

deep within C++ decimal.h
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, _T2) \
inline _T1& _T1::operator _Op1(_T2 __rhs) \
{ \
__setval(__getval() _Op2 __rhs); \
return *this; \
}

Name: Anonymous 2016-01-04 12:17

FrozenAnus is talking to himself again

Name: Anonymous 2016-01-05 7:12

Lazy evaluation is so detrimental to performance,Simon Peyote Jones said "The next Haskell would be strict".

Name: Anonymous 2016-01-06 10:52

>>20
opapply will be added to next sepples standard as "fold expressions"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4295.html

Name: Anonymous 2016-01-06 10:57

>>37
to simulate opapply, you have to forward arglist of wrapped apply(<>) and
then use fold expression to inject operators.
It will also be much slower.

Name: Anonymous 2016-01-06 11:41

C++ is like an elephant trying to dance by dance template

Name: Anonymous 2016-01-06 11:43

..and C is a knife juggling clown on unicycle

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