This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flatten is indeed an interesting topic - one cool thing is that flatMap is just map followed by flatten, i.e. (ma flatMap f) == (ma map f flatten) [1]. | |
Another is that flatten is flatMap(identity) [2][3]. | |
Another is that a monad can be defined as a functor with a unit function (i.e. a type constructor like List or Option) and a flatten function (aka join in Haskell) [4] | |
[1] https://github.com/philipschwarz/scala-fp-combinators-code-kata/blob/master/src/main/scala/FPCombinatorsCodeKata.scala#L18 - https://www.slideshare.net/pjschwarz/scala-functional-programming-combinators-code-kata | |
[2] https://github.com/philipschwarz/scala-fp-combinators-code-kata/blob/master/src/main/scala/FPCombinatorsCodeKata.scala#L20 | |
[3] https://www.slideshare.net/pjschwarz/symmetry-in-the-interrelation-of-flatmapfoldmaptraverse-and-flattenfoldsequence | |
[4] https://www.slideshare.net/pjschwarz/monad-as-functor-with-pair-of-natural-transformations#8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file was automatically generated by 'stack init' | |
# | |
# Some commonly used options have been documented as comments in this file. | |
# For advanced use and comprehensive documentation of the format, please see: | |
# https://docs.haskellstack.org/en/stable/yaml_configuration/ | |
# Resolver to choose a 'specific' stackage snapshot or a compiler version. | |
# A snapshot resolver dictates the compiler version and the set of packages | |
# to be used for project dependencies. For example: | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: sierpinski | |
version: 0.1.0.0 | |
github: "githubuser/sierpinski" | |
license: BSD3 | |
author: "Author name here" | |
maintainer: "[email protected]" | |
copyright: "2021 Author name here" | |
extra-source-files: | |
- README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Lib | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# OPTIONS -Wall -fno-warn-type-defaults #-} | |
import Graphics.Gloss | |
import Data.Monoid | |
window :: Display |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.effect._ | |
import cats.effect.unsafe.implicits.global | |
import fs2._ | |
import java.time.Instant | |
import scala.concurrent.duration._ | |
object Mine extends App { | |
val s = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import anticipation.Text | |
import gossamer.t | |
import quantitative.{Kilograms, Metres, Quantity} | |
import turbulence.Out | |
type Bmi = Quantity[Kilograms[1] & Metres[-2]] | |
case class Person( | |
name: Text, | |
age: Int, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ThisBuild / version := "0.1.0-SNAPSHOT" | |
ThisBuild / scalaVersion := "3.5.0" | |
lazy val root = (project in file(".")) | |
.settings( | |
name := "try-contingency" | |
) | |
libraryDependencies += "dev.soundness" % "quantitative-core" % "0.1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala: ## Exception when compiling 1 sources to /Users/philipschwarz/dev/git/try-contingency/target/scala-3.5.0/classes | |
java.lang.AssertionError: assertion failed: class inequality has non-class parent: AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object hypotenuse),Inequality),List(AppliedType(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object quantitative),module class Quantitative$)),type Quantity),List(TypeRef(ThisType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object quantitative),module class Quantitative$)),module class Quantity$)),class inequality)),type UnitsType))), AppliedType(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object quantitative),module class Quantitative$)),type Quantity),List(TypeRef(ThisType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object quantitative),module class Quanti |
OlderNewer