This file contains 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
{-# LANGUAGE RankNTypes, TypeInType, TypeApplications, OverloadedLabels, | |
ScopedTypeVariables, TypeOperators, GADTs, FlexibleInstances, FlexibleContexts, | |
TypeFamilies, UndecidableInstances #-} | |
import Data.Kind (Type) | |
import Data.Proxy (Proxy(..)) | |
import GHC.Generics | |
import GHC.TypeLits (Symbol, KnownSymbol, symbolVal) | |
import Control.Lens | |
import Data.Generics.Product.Fields (field') |
This file contains 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
-- Compile with | |
-- ghc -Wall -O -fforce-recomp -ddump-simpl -dsuppress-all poly.hs | |
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module Poly (value, ualue, xalue) where | |
import Data.Proxy (Proxy (..)) |
This file contains 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 Unsafe.Coerce | |
y :: (a -> a) -> a | |
y = \f -> (\x -> f (unsafeCoerce x x))(\x -> f (unsafeCoerce x x)) | |
-- Ref: [Y Combinator in Haskell](http://stackoverflow.com/questions/4273413/y-combinator-in-haskell) | |
-- a fibonacci example | |
main = putStrLn $ show $ y (\fact -> \n -> if n < 2 then 1 else n * fact (n - 1)) 5 |