Skip to content

Instantly share code, notes, and snippets.

View Baccata's full-sized avatar

Olivier Mélois Baccata

View GitHub Profile
import shapeless._
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// THE IMPLICIT CLASS THAT ALLOWS TO CALL #copy ON ANY SEALED TRAIT INSTANCE
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
object copySyntax {
implicit class CopySyntax[TypeToCopy](thingToCopy: TypeToCopy) {
module Main where
main = putStrLn (show (fforall (\x -> (x >= -1000)) (setInt)))
type Set a = a -> Bool
setInt :: Set Int
setInt = \x -> True
--filtering the range with the set function and checking if all elements from the set satisfy the predicate
fforall :: Restrict a => (a -> Bool) -> Set a -> Bool
@Baccata
Baccata / Bool.scala
Created February 25, 2015 22:44
Implementation of typelevel booleans and integers using type projections
package baccata
/**
* Inspired from Grant Beaty's Scunits
*/
trait Bool {
type branch[B,T <: B, E <: B] <: B // typelevel if-then-else
type not <: Bool
type or[R <: Bool] <: Bool
type and[R <: Bool] <: Bool