Custom Query (7491 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (1 - 3 of 7491)

1 2 3 4 5 6 7 8 9 10 11
Ticket Resolution Summary Owner Reporter
#10128 fixed Data.List.transpose needs more docs ekmett nomeata
Description

as mentioned by Doug McIlroy on haskell-prime.

My preference in the interest of brevity would be to not include the equations that Doug mentioned and simply add his nicely constructed educating example to the docs:

The transpose function transposes the rows and columns of its argument. For example,

transpose [[1,2,3],[4,5,6]] == [[1,4],[2,5],[3,6]]

If some of the rows are shorter than the following rows, their elements are skipped:

transpose [[10,11],[20],[],[30,31,32]] == [[10,20,30],[11,31],[32]]
#10125 invalid Improper evaluation of type families danilo2
Description

Hello! I've got here a small piece of code:

{-# LANGUAGE DeriveDataTypeable   #-}
{-# LANGUAGE EmptyDataDecls       #-}
{-# LANGUAGE DataKinds            #-}
{-# LANGUAGE PolyKinds            #-}
{-# LANGUAGE TypeFamilies         #-}
{-# LANGUAGE TypeOperators        #-}
{-# LANGUAGE UndecidableInstances #-}

module Data.TypeLevel.Bool where

import Prelude hiding (Eq)
import qualified Prelude as P
import           Data.Typeable

import GHC.TypeLits

type family Eq (a :: k) (b :: k) where
    Eq a a = True
    Eq a b = False


type family If (cond :: Bool) (a :: k) (b :: k) where
  If True  a b = a
  If False a b = b


type family CmpBy (f :: k -> k -> Ordering) (a :: [k]) (b :: [k]) :: Ordering where
    CmpBy f '[] '[] = EQ
    CmpBy f (a ': as) (b ': bs) = If (Eq (f a b) EQ) (CmpBy f as bs) (f a b)


type family TCompare (a :: [Nat]) (b :: [Nat]) :: Ordering where
    TCompare '[] '[] = EQ
    TCompare (a ': as) (b ': bs) = If (Eq a b) (TCompare as bs) (CmpNat a b)


type N1 = '[1,2,3,5]
type N2 = '[1,2,3,4]

main = do
        print $ (Proxy :: Proxy GT) == (Proxy :: Proxy (TCompare N1 N2))
        print $ (Proxy :: Proxy GT) == (Proxy :: Proxy (CmpBy CmpNat N1 N2))

It does NOT compile, while it should. The type-level functions TCompare and CmpBy CmpNat should work exactly the same way. Right now the former one always returns EQ, so the program does not compile with an error:

Bool.hs:49:41:
    Couldn't match type ‘'EQ’ with ‘'GT’
    Expected type: Proxy (CmpBy CmpNat N1 N2)
      Actual type: Proxy 'GT
    In the second argument of ‘(==)’, namely
      ‘(Proxy :: Proxy (CmpBy CmpNat N1 N2))’
    In the second argument of ‘($)’, namely
      ‘(Proxy :: Proxy GT) == (Proxy :: Proxy (CmpBy CmpNat N1 N2))’
#10123 invalid GHCi won't start in Powershell ISE qwfy
Description

To reproduce,

  1. Start Powershell ISE (Windows PowerShell ISE Host 4.0 on Windows 8.1)
  2. Type "ghci"

You will see the output:

GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

After Loading package base ... linking ... done., GHCi just hangs, won't continue, the prompt is never displayed.

1 2 3 4 5 6 7 8 9 10 11
Note: See TracQuery for help on using queries.