Posts

Showing posts with the label types

scala type class with higher kinded types and variance

scala type class with higher kinded types and variance I have a question very similar to this one: Scala higher kinded type variance This, however is slightly different in that, well, it doesn't compile (scala 2.11.8). The basic idea is to take a provided array of "things". If the array is null, return a default value of some type (e.g. Boolean , Option , List[Int] ), otherwise do work on the array and produce a result. The result and default value have the same type. Boolean Option List[Int] The challenge I'm having is getting this to work across a broad set of result types. Here's a contrived example: trait NullGuard[F[_]] { def nullGuard[A, B](arr: Array[A], default: F[B])(expr: => F[B]): F[B] = if (arr == null || arr.length == 0) default else expr } Let's create an implementation that returns an Option: implicit def optionNullGuard[F[X] <: Option[X]]: NullGuard[F] = new NullGuard[F]() {} The above does compile, but the following att...

'Frame' has no attribute 'tk' - Python Thinter

'Frame' has no attribute 'tk' - Python Thinter I try resolve my problem with this message from PyCharm and Idle. 'type object 'Frame' has no attribute 'tk'' What this mean? Why Python don't show new window with 3 Buttons? Thank you very much for your help! from tkinter import* class Application(Frame): def __init__(self, master): """ Frame """ super(Application, self).__init__(master) self.grid() self.create_widgets() def create_widgets(self): """Buttons""" #Buttons1 self.bttn1 = Button("Test1") self.bttn1.grid() #Buttons2 self.aaaa2 = Button(self) self.aaaa2.grid() self.aaaa2.configure(text="Test2") #Buttons3 self.bttn3 = Button (self) self.bttn3.grid() self.bttn3["text"] = "Test3" #Main part of the program ro...