News for hackers. Stuff that matters.
Re:Show HN: Koda, a typesafe functional toolkit for Python by dragonwriter on Monday February 07, 2022 @08:16PM (#30253825)
> Additionally lambda syntax, aka python anonymous first class functions HAVE to be functional.

They have to be a single python expression, but that’s not the same as the usual understanding of “functional” (i.e., referentially transparent). Consider:

  d = {"foo": 1}
  f = lambda m: d.update({k, v+d.get(k,0) for k,v in m.items()}) or d
> Tail slices on lists like x[1:] cost O(N) and that's the biggest issue right now imo. It makes some valid solutions on leetcode exceed the time limit because it adds and additional N complexity on every slice when the head and tail functions in haskell cost O(1)

Python lists are not lisp-style lists, which is more efficient for most uses, but not for a lot of functional-style algorithms which leverage cheap head/tail splits.

But it wouldn't be hard to write a typed sequence class that wrapped a lisp-style immutable list implemented with nested tuples with the deepest nested one an empty tuple in Python, there's just not a lot of demand for it.

Re:Show HN: Koda, a typesafe functional toolkit for Python by deltaonefour on Monday February 07, 2022 @09:06PM (#30254115)
>They have to be a single python expression, but that’s not the same as the usual understanding of “functional” (i.e., referentially transparent). Consider:

True, yeah

>But it wouldn't be hard to write a typed sequence class that wrapped a lisp-style immutable list implemented with nested tuples with the deepest nested one an empty tuple in Python, there's just not a lot of demand for it.

A doubly linked list with the same slice syntax would be fine. You can use java style classes as it's just the underlying implementation. There's no demand (currently) but it's a good idea as python syntax works extremely well (better then even javascript) for functional programming.